§9.11. Future events
We often want to arrange for something to happen at some point in the future. Here is yet another timepiece:
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.
| ExampleMRE Hunger that eventually kills the player, and foodstuffs that can delay the inevitable by different amounts of time.
|
|
First we define the events, and then we create a phrase to schedule them:
"Totality"
At the time when the penumbra appears:
say "The sunlight dies away to an eerie, brownish penumbra."
At the time when the eclipse begins:
say "The moon passes across the disc of the sun, plunging the world into darkness.";
now the Chamber is dark.
At the time when the eclipse ends:
say "The moon passes away from the sun, and a gloomy penumbral light returns.";
now the Chamber is lighted.
At the time when normal sunlight returns:
say "The sun shines once more bright in the sky, not to be eclipsed again on this spot for another thirty-seven years."
To schedule an eclipse for (totality - a time):
the penumbra appears at two minutes before totality;
the eclipse begins at totality;
the eclipse ends at three minutes after totality;
normal sunlight returns at five minutes after totality.
Now we make use of the new phrase:
When play begins, schedule an eclipse for 3:27 PM.
The Chamber is a room.
The time of day is 3:25 PM.
Test me with "z / z / z / z / z / z / z / z / z".
We shall see much more about creating phrases later. Their advantage is that they enable a complicated sequence of operations to be given a meaningful name, and that they can be re-used many times as needed.
|  ExampleTotality To schedule an eclipse of the sun, which involves a number of related events.
|
First we define the events, and then we create a phrase to schedule them:
"Totality"
At the time when the penumbra appears:
say "The sunlight dies away to an eerie, brownish penumbra."
At the time when the eclipse begins:
say "The moon passes across the disc of the sun, plunging the world into darkness.";
now the Chamber is dark.
At the time when the eclipse ends:
say "The moon passes away from the sun, and a gloomy penumbral light returns.";
now the Chamber is lighted.
At the time when normal sunlight returns:
say "The sun shines once more bright in the sky, not to be eclipsed again on this spot for another thirty-seven years."
To schedule an eclipse for (totality - a time):
the penumbra appears at two minutes before totality;
the eclipse begins at totality;
the eclipse ends at three minutes after totality;
normal sunlight returns at five minutes after totality.
Now we make use of the new phrase:
When play begins, schedule an eclipse for 3:27 PM.
The Chamber is a room.
The time of day is 3:25 PM.
Test me with "z / z / z / z / z / z / z / z / z".
We shall see much more about creating phrases later. Their advantage is that they enable a complicated sequence of operations to be given a meaningful name, and that they can be re-used many times as needed.
First we define the events, and then we create a phrase to schedule them:
"Totality"
At the time when the penumbra appears:
say "The sunlight dies away to an eerie, brownish penumbra."
At the time when the eclipse begins:
say "The moon passes across the disc of the sun, plunging the world into darkness.";
now the Chamber is dark.
At the time when the eclipse ends:
say "The moon passes away from the sun, and a gloomy penumbral light returns.";
now the Chamber is lighted.
At the time when normal sunlight returns:
say "The sun shines once more bright in the sky, not to be eclipsed again on this spot for another thirty-seven years."
To schedule an eclipse for (totality - a time):
the penumbra appears at two minutes before totality;
the eclipse begins at totality;
the eclipse ends at three minutes after totality;
normal sunlight returns at five minutes after totality.
Now we make use of the new phrase:
When play begins, schedule an eclipse for 3:27 PM.
The Chamber is a room.
The time of day is 3:25 PM.
Test me with "z / z / z / z / z / z / z / z / z".
We shall see much more about creating phrases later. Their advantage is that they enable a complicated sequence of operations to be given a meaningful name, and that they can be re-used many times as needed.
|
|  ExampleEmpire A train which follows a schedule, stopping at a number of different locations.
|
|