§19.2. Named rules and rulebooks
Most of the rules built into Inform have names. For instance, a rule called "the advance time rule" is the one which increments the number of turns - usually visible on the "status line" displayed above the window of a game in progress - and advances the clock, which is usually not visible, but ticking away behind the scenes.
A rulebook is a list of rules to be followed in sequence until one of them makes a decision. For instance, when actions get to the "instead" stage, each "instead" rule is tried until one of them chooses to do something. If the source text contains the rules
Instead of taking something: say "You have no particular need just now."
Instead of taking a fish: say "It's all slimy."
and a command to TAKE something is tried, then only one of these rules will have any effect. The "instead" rulebook contains:
Rule (1) to be applied if the action matches "taking a fish"
Rule (2) to be applied if the action matches "taking something"
Inside their rulebook, the rules are not listed in the order of definition in the source text. Rule (1) comes before rule (2) because it applies in more specific circumstances. This is the main idea: a rulebook gathers together rules about making some decision, or taking some action, and sorts them in order to give the more specific rules first choice about whether they want to intervene.
Whereas only some rules are named (the two "instead" rules above have no name, for instance), every rulebook has a name. For convenience, the following forms of rule and rulebook name are synonymous:
advance time = the advance time rule
the instead rules = instead rulebook = instead
The names of built-in rules have been chosen as descriptively as possible: the "can't go through closed doors rule", for instance. Names for rules tend to be verbose, but this is a situation where clarity is very much better than brevity.
Nine AM Appointment
If there's some reason the player needs to be at a specific place and time, we might want to allow him to wait a number of minutes at once.
"Nine AM Appointment"
Waiting more is an action applying to one number.
Understand "wait [a time period]" or "wait for [a time period]" or "wait for a/an [a time period]" or "wait a/an [a time period]" as waiting more.
Carry out waiting more:
let the target time be the time of day plus the time understood;
decrease the target time by one minute;
while the time of day is not the target time:
follow the turn sequence rules.
The one nuance here is that after our wait command occurs, the turn sequence rules will occur one more time. So we need to subtract one minute from the parsed time to make the turn end on the desired number of minutes.
Report waiting more:
say "It is now [time of day + 1 minute]."
And if we want to ensure that the player doesn't (accidentally or intentionally) put the interpreter through a really long loop, we could put an upper limit on his patience:
Check waiting more:
if the time understood is greater than one hour, say "You really haven't got that kind of patience." instead.
The Specialist's Office is a room. The secretary is a woman in the Office. Instead of asking the secretary about "[appointment]", say "'Hang on just five more minutes,' she says, in a distracted manner."
Understand "appointment" or "specialist" or "doctor" as "[appointment]".
At 9:45 AM: say "At [the time of day in words], secretary glances at you and gives a reassuring smile."
Test me with "ask secretary about appointment / wait five minutes / g / g / wait 61 minutes / wait for half an hour / wait for a quarter of an hour / wait for an hour".
Hanging around until is an action applying to one time.
Check hanging around until:
if the time of day is the time understood, say "It is [time understood] now!" instead;
if the time of day is after the time understood, say "It is too late for that now." instead.
Carry out hanging around until:
while the time of day is before the time understood:
follow the turn sequence rules.
Report hanging around until:
say "You yawn until [time understood]."
Understand "wait until [time]" as hanging around until.
The Empty Field is a room. "It's an ordinary empty field. Nothing to see here at all-- yet. Wait until 11:45 PM, though."
At 11:45 PM:
say "Suddenly the air is filled with light and the sounds of an approaching band. Over the crest of the hill comes a parade of singing, stomping, hooting people: and not just people, but dogs, horses, elephants, giraffes... There are banners, and candles, and a flag that glows eerie-green in the dark; there is a float shaped like an enormous turtle, its shell covered with winking green lights; there is an old man dressed as a skeleton, carried in a litter, his neck garlanded with dried chiles. There are small girls throwing rose petals from a basket, and grown women half-naked carrying the emblems of Bacchic revelry, and two little boys each with a silver basin of clear water. All these go by in procession, and you join on at the end.";
end the story finally.
Test me with "look / z / z / wait until 11:45 PM".