§9.11. Future events

We often want to arrange for something to happen at some point in the future. Here is yet another timepiece:

paste.png An egg-timer is in the Chamber. "A plastic egg timer in the shape of a chicken can be pressed to set it going."

Instead of pushing the egg-timer:
    say "It begins to mark time.";
    the egg-timer clucks in four turns from now.

At the time when the egg-timer clucks:
    say "Cluck! Cluck! Cluck! says the egg-timer."

The event here is called "the egg-timer clucks". It only happens if we instruct so, using one of the following phrases:

(rule) in (time) from now

This phrase causes the given rule to be run at a given time offset from the current time of day. Example:

the egg-timer clucks in 18 minutes from now;

(rule) in (number) turn/turns from now

This phrase causes the given rule to be run at a given number of turns after the current one. Example:

the egg-timer clucks in four turns from now;

(rule) at (time)

This phrase causes the given rule to be run at a given time of day. Example:

the egg-timer clucks at 11:35 AM;

If we know in advance what time we want something to happen, we can more simply write:

At 4 PM: say "The great bells of the clock tower chime four."

(Note that in either case such rules begin with the word "at": they are the only rules allowed to begin with the word "at".)

A small warning: timed events like these only have a chance to occur during the turn sequence, that is, once every turn. In most stories, one turn takes one minute, so there will in due course be a turn happening at exactly (say) 11:35 AM. But if the clock is being advanced faster than this, it's possible that there are turns at (say) 11:32 AM and then not until 11:37 AM. But an event set for 11:35 AM will nevertheless happen -- it will run at the first available turn after that time, which will be 11:37 AM. Events can thus happen up to half an hour late, though Inform cancels them if the elapsed time is greater than that.

The Scenes panel of the Index can be a useful way to see what events have been set.


arrow-up.pngStart of Chapter 9: Time
arrow-left.pngBack to §9.10. Calculating times
arrow-right.pngOnward to §9.12. Actions as conditions

*ExampleMRE
Hunger that eventually kills the player, and foodstuffs that can delay the inevitable by different amounts of time.

**ExampleTotality
To schedule an eclipse of the sun, which involves a number of related events.

Suppose we want to have a train which, at fixed times, arrives at and leaves stations. It should be possible for the player to get on and off the train when it is stopped, but not while the train is in motion.

paste.png "Empire"

The Empire Builder Train is a room. The Train has a room called the station. The station of the Train is Seattle.

The description of the Empire Builder is "One of the (relatively) plush long-distance Amtrak trains. You're in a two-story car with toilets and a cafe at one end, not having sprung for a sleeper.

[if the station of the Train is the train]Outside the window there is rapidly-passing countryside.[otherwise]Through the windows you can see the [station of the Train] train station.[end if]"

Instead of exiting when the player is in the Train:
    if the station of the Train is the Train:
        say "The train is not stopped at a station." instead;
    otherwise:
        move the player to the station of the train instead.

Before going outside when the player is in the Train:
    try exiting instead.

Before going inside when the player is in the station of the Train:
    move the player to the Train instead.

Seattle, Edmonds, Everett, Wenatchee, and Spokane are rooms. The description of a room is usually "The scenic train station of [the location][if the location is the station of the train].

The pompously-titled Empire Builder train is pulled up here, soon to continue its journey towards Chicago[end if]."

And now our schedule for the train -- somewhat truncated, admittedly, since the full three-day journey from Seattle to Chicago is a bit long even for an ambitious example.

At 4:45 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train]!";
    now the station of the Train is the Train.

At 5:10 PM:
    now the station of the Train is Edmonds;
    if the player is in the train or the player is in the station of the train, say "The train pulls into Edmonds and comes to a stop."

At 5:17 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train], running north along the shore towards Everett.";
    now the station of the Train is the Train.

At 5:39 PM:
    now the station of the Train is Everett;
    if the player is in the train or the player is in the station of the train, say "The train arrives in scenic Everett, WA: the last stop before it turns east and heads over the mountains."

At 5:44 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train] and turns east.";
    now the station of the Train is the Train.

At 8:39 PM:
    if the player is in the train or the player is in the station of the train, say "In darkness the train rolls into Wenatchee; which is just fine, considering that there is nothing to see here at all.";
    now the station of the Train is Wenatchee.

At 8:44 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train] and continues east through the darkness towards Spokane.";
    now the station of the Train is the Train.

Playing this out would of course require near inhuman patience. Let's set things up so that the player at least doesn't have to wait too long for his first departure:

The time of day is 4:43 PM.

...and provide fair warning of how slowly time is elapsing.

When play begins:
    now the right hand status line is "[time of day]".

Test me with "out / in / z/ z / z / out / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / out / in / out / z / z".

Test more with "out / z/ z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z".

**ExampleEmpire
A train which follows a schedule, stopping at a number of different locations.

Suppose we want to have a train which, at fixed times, arrives at and leaves stations. It should be possible for the player to get on and off the train when it is stopped, but not while the train is in motion.

paste.png "Empire"

The Empire Builder Train is a room. The Train has a room called the station. The station of the Train is Seattle.

The description of the Empire Builder is "One of the (relatively) plush long-distance Amtrak trains. You're in a two-story car with toilets and a cafe at one end, not having sprung for a sleeper.

[if the station of the Train is the train]Outside the window there is rapidly-passing countryside.[otherwise]Through the windows you can see the [station of the Train] train station.[end if]"

Instead of exiting when the player is in the Train:
    if the station of the Train is the Train:
        say "The train is not stopped at a station." instead;
    otherwise:
        move the player to the station of the train instead.

Before going outside when the player is in the Train:
    try exiting instead.

Before going inside when the player is in the station of the Train:
    move the player to the Train instead.

Seattle, Edmonds, Everett, Wenatchee, and Spokane are rooms. The description of a room is usually "The scenic train station of [the location][if the location is the station of the train].

The pompously-titled Empire Builder train is pulled up here, soon to continue its journey towards Chicago[end if]."

And now our schedule for the train -- somewhat truncated, admittedly, since the full three-day journey from Seattle to Chicago is a bit long even for an ambitious example.

At 4:45 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train]!";
    now the station of the Train is the Train.

At 5:10 PM:
    now the station of the Train is Edmonds;
    if the player is in the train or the player is in the station of the train, say "The train pulls into Edmonds and comes to a stop."

At 5:17 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train], running north along the shore towards Everett.";
    now the station of the Train is the Train.

At 5:39 PM:
    now the station of the Train is Everett;
    if the player is in the train or the player is in the station of the train, say "The train arrives in scenic Everett, WA: the last stop before it turns east and heads over the mountains."

At 5:44 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train] and turns east.";
    now the station of the Train is the Train.

At 8:39 PM:
    if the player is in the train or the player is in the station of the train, say "In darkness the train rolls into Wenatchee; which is just fine, considering that there is nothing to see here at all.";
    now the station of the Train is Wenatchee.

At 8:44 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train] and continues east through the darkness towards Spokane.";
    now the station of the Train is the Train.

Playing this out would of course require near inhuman patience. Let's set things up so that the player at least doesn't have to wait too long for his first departure:

The time of day is 4:43 PM.

...and provide fair warning of how slowly time is elapsing.

When play begins:
    now the right hand status line is "[time of day]".

Test me with "out / in / z/ z / z / out / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / out / in / out / z / z".

Test more with "out / z/ z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z".

Suppose we want to have a train which, at fixed times, arrives at and leaves stations. It should be possible for the player to get on and off the train when it is stopped, but not while the train is in motion.

paste.png "Empire"

The Empire Builder Train is a room. The Train has a room called the station. The station of the Train is Seattle.

The description of the Empire Builder is "One of the (relatively) plush long-distance Amtrak trains. You're in a two-story car with toilets and a cafe at one end, not having sprung for a sleeper.

[if the station of the Train is the train]Outside the window there is rapidly-passing countryside.[otherwise]Through the windows you can see the [station of the Train] train station.[end if]"

Instead of exiting when the player is in the Train:
    if the station of the Train is the Train:
        say "The train is not stopped at a station." instead;
    otherwise:
        move the player to the station of the train instead.

Before going outside when the player is in the Train:
    try exiting instead.

Before going inside when the player is in the station of the Train:
    move the player to the Train instead.

Seattle, Edmonds, Everett, Wenatchee, and Spokane are rooms. The description of a room is usually "The scenic train station of [the location][if the location is the station of the train].

The pompously-titled Empire Builder train is pulled up here, soon to continue its journey towards Chicago[end if]."

And now our schedule for the train -- somewhat truncated, admittedly, since the full three-day journey from Seattle to Chicago is a bit long even for an ambitious example.

At 4:45 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train]!";
    now the station of the Train is the Train.

At 5:10 PM:
    now the station of the Train is Edmonds;
    if the player is in the train or the player is in the station of the train, say "The train pulls into Edmonds and comes to a stop."

At 5:17 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train], running north along the shore towards Everett.";
    now the station of the Train is the Train.

At 5:39 PM:
    now the station of the Train is Everett;
    if the player is in the train or the player is in the station of the train, say "The train arrives in scenic Everett, WA: the last stop before it turns east and heads over the mountains."

At 5:44 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train] and turns east.";
    now the station of the Train is the Train.

At 8:39 PM:
    if the player is in the train or the player is in the station of the train, say "In darkness the train rolls into Wenatchee; which is just fine, considering that there is nothing to see here at all.";
    now the station of the Train is Wenatchee.

At 8:44 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train] and continues east through the darkness towards Spokane.";
    now the station of the Train is the Train.

Playing this out would of course require near inhuman patience. Let's set things up so that the player at least doesn't have to wait too long for his first departure:

The time of day is 4:43 PM.

...and provide fair warning of how slowly time is elapsing.

When play begins:
    now the right hand status line is "[time of day]".

Test me with "out / in / z/ z / z / out / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / out / in / out / z / z".

Test more with "out / z/ z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z".

***ExampleHour of the Wren
Allowing the player to make an appointment, which is then kept.