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.