At [A time that varies]:

I am attempting to use the following code as part of a larger story but it seems that inform is unable to understand At with a time that varies.


Sunrise is a time that varies. Sunrise is 9 AM.

At Sunrise:
	say "The first rays of sun shine over the horizon."

However I get the following error message as it seems inform does not recognize sunrise as a description of a time.

Problem. You wrote ‘At sunrise’ (line 153): but ‘at’ what time? No description of a time is given, which means that this rule can never have effect. (The convention is that any rule beginning ‘At’ is a timed one. The time can either be a fixed time, as in ‘At 11:10 AM: …’, or the time when some named event takes place, as in ‘At the time when the clock chimes: …’.)

What I am trying to accomplish is to have a variable sunrise that I can change each season or even each day to change when outdoor rooms are provided light from the sun (by moving the sun backdrop which is lighted to all outdoors rooms), so I don’t just want it to be At 9AM:.

Is it simply impossible to use At with a time that varies (that isn’t a scene) or is there something I’m missing with the syntax? If it isn’t possible is a scene the only work around or what other ways could I achieve this?

The compiler doesn’t seem to want to accept a variable in that place. One workaround would be:

"Sunrise"

Place is a room.

Sunrise is a time that varies. Sunrise is 9 AM.

When play begins:
    sunrise occurs at sunrise.

At the time when sunrise occurs:
    say "The first rays of sun shine over the horizon."

See WWI 9.11 Future Events for more. As described there, timed events can be rescheduled at will during story execution. For example:

"Sunrise"

Place is a room.

Sunrise is a time that varies. Sunrise is 9 AM.

When play begins:
    sunrise occurs at sunrise.

At the time when sunrise occurs:
    say "The first rays of sun shine over the horizon."

After waving hands:
    now sunrise is the time of day plus one minute;
    sunrise occurs at sunrise.
    
Test me with "z / z / z / wave / z / z / wave / z".
3 Likes

Note also that the “At …” event system isn’t really set up for recurring events like you seem to be writing. It also can’t set up events more than 24 hours into the future (since you can’t specify “tomorrow” or anything like that). It’s probably more versatile to use a rule like this:

Sunrise is a time that varies. Sunrise is at 9:05 AM.
Currently-Daytime is a truth state that varies. Currently-Daytime is initially false.
Every turn when the time of day is after Sunrise and Currently-Daytime is false:
    say "Rise and shine";
   now Currently-Daytime is true.
3 Likes

Thanks to both of you. I’ll try out both of these methods.