Before Describing a room Interrupt and darkness

Hi again.

I’m using Inform7 as a way to introduce my students to coding. It’s excellent for teaching attention to detail, coding syntax, and, best of all, their work is immediately accessible to them as a game.

They’ve got some basic skills sorted and I’m now trying to encourage them to add better descriptions with hints for action.

I’m aware that dark and lighted is a tricky area, so that aspect of this is more for me than them, but the idea of interrupting a description is something I’d like them to be able to do.

In this case I’d like the game to make the determination of whether it is light or dark and react accordingly before describing the room (or not) so there aren’t double descriptions, as shown below.

>look
bedroom
You are in your bedroom. A storm is raging outside.

It is now pitch dark in here!

>look
Darkness
It is pitch dark, and you can't see a thing.

bedroom
You are in your bedroom. A storm is raging outside.

>
Volume 1 - TIMES

Every turn when a random chance of 1 in 2 succeeds and the bedroom is lighted:
now the bedroom is dark.
	
Every turn when a random chance of 1 in 2 succeeds and the bedroom is dark:
now the bedroom is lighted.


Book 1 - 


Volume 2 - Initializing

when play begins:
	say "You are lying in bed. Outside a storm rages. Rolling thunder shakes the roof and rattles the windows, while lightning splits the sky bathing the interior of the room in intense light then pitching it into total darkness.".
	.

Volume 3 - HOUSE ROOMS

Book 1 - Bedroom

Part 1 - Room Details

Chapter 1- Description

Section 1- Printed

The bedroom is a room. "You are in your bedroom. A storm is raging outside.".

	
Chapter 2 - Rules



Part 2 - Objects

Section 1 - Curtains

The curtain is in the bedroom.

The curtain is scenery.

I’m beginning with the player in a room that is light and dark randomly by lightning

2 Likes

The thing to realise here is that “every turn” rules occur after the action of the turn and immediately prior to the subsequent turn. From that perspective, the behaviour above makes perfect sense.

There are ways to alter this, but they may not necessarily be what you’re after.

One option is to make it so that it doesn’t look twice on a single turn:

For printing the announcement of light when the current action is looking:
	say "The room has become illuminated."

… but this won’t actually print the new room description (unless they were doing something other than looking on that turn), so the player will have to waste a turn looking again anyway.

Possibly a better option might be to do the changing of light somewhere other than in every turn, but again exactly where makes more sense might vary depending on what you’re trying to actually do. I assume random lighting isn’t really the final goal.

1 Like

This is trickier than it sounds. By placing the lighting change in an “every turn” rule, you’re saying that it happens after the player’s action. It would make more sense if you put in an explicit description of the change:

>look
bedroom
You are in your bedroom. A storm is raging outside.

The lights go out!

It is now pitch dark in here!

>look
Darkness
It is pitch dark, and you can't see a thing.

The lights come on!

bedroom
You are in your bedroom. A storm is raging outside.

(This is the same as your code, except with extra say statements.) (Okay, and some rearrangement to avoid the possibility of two changes in one turn, but let’s not get into that right now…)

It seems like you’re asking for the (possible) lighting change to happen after the player types LOOK, but before the room description.

There’s an implicit convention that the player’s command happens in the situation that was described at the end of the last turn! If you implement what I just said, you get this uncomfortable result:

>look
bedroom
You are in your bedroom. A storm is raging outside.
You see your bathrobe here.

>get bathrobe
The lights go out!
You can't see any such thing.
It is now pitch dark in here!

Maybe you want the game to be that frustrating, but you’ll have to decide that.

2 Likes

If you’re wanting to model the lightning flashes being the only illumination of the room, perhaps the standard light/dark model isn’t really the right way to do it at all.

Typically a lightning flash would only very briefly illuminate the room, not long enough for an actual turn to occur. Thus the room should actually permanently be in darkness, but perhaps each lightning flash might let you see some additional items in the room, or some additional time would pass waiting for a flash to illuminate whatever thing the player is trying to examine on that turn.

This could be done purely through flavour text and descriptions (and perhaps tracking a count of number of flashes that have occurred, to reveal progressively more information), rather than actually making the room dark in an Inform model sense.

And you could also use multiple “rooms” inside the bedroom, perhaps to model things like navigating past a coffee table without banging your shins too hard on it.

1 Like

Thank you for the reply. I will digest that and do some practicing to fully understand it.

Just in case it is significant, the “look” command was a placeholder as I wanted to check that the light and dark would work.

The intention is not to annoy the player as they can get up and move to a light switch. The idea was to illustrate that you could have random things happening that could make their “rooms” feel more real. I’ve shown them how to have animals moving randomly around and to randomly describe the contents of a room. I thought lighted and dark might be a good way to add some atmosphere without it being time of day related (which I have shown them).

Do you have any other suggestions?

1 Like

That’s a really good idea. Thank you for the help.

1 Like

Darkness, in the Inform model sense, is a very heavy switch. Think of it as moving the player to an entirely different room (which is almost but not quite entirely true) rather than changing the state of the existing room. Everything in the original room becomes non-interactable; generally only exits continue to function (and even then, not things like closed doors).

There are ways to mitigate this and to enable special behaviour, but it’s perhaps getting a bit esoteric for students.

Perhaps rather than hard darkness, you could look into having different descriptions based on time of day (morning vs. evening) or have some dim ambient light when the lights are off instead, such that you’re using conditional text in descriptions as the main variations.

Another thing that you could perhaps focus on for enhanced realism is the “other four senses” actions that are often overlooked – touching, smelling, listening, and tasting.

2 Likes

These are also great ideas.

They have their time of day sorted, and are using the times to specify when things are and are not in locations. Dark and lighted is perhaps for another time.