§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.


arrow-up.pngStart of Chapter 19: Rulebooks
arrow-left.pngBack to §19.1. On rules
arrow-right.pngOnward to §19.3. New rules

*ExampleNine AM Appointment
A WAIT [number] MINUTES command which advances through an arbitrary number of turns.

**ExampleDelayed Gratification
A WAIT UNTIL [time] command which advances until the game clock reaches the correct hour.