Inform 7 Home Page / Documentation

§19.8. New rulebooks

Creating a new rulebook is also straightforward, as we see in the following modest example story:

paste.png "Appraisal"

The Passage is east of the Tomb. The green-eyed idol is in the Tomb. A Speak-Your-Progress machine is in the Passage.

Appraisal rules is a rulebook.

An appraisal rule: say "Click... whirr... the score is [the score in words] points."

An appraisal rule:
    if we have taken the idol, say "Most importantly of all, the idol has been found."

Instead of switching on the machine, follow the appraisal rules.

The creation of the rulebook is all very well, but without the final sentence it would never be used. The crucial new phrase here is:

follow (rule)

This phrase causes the rule to be obeyed immediately (rather than simply at predetermined times such as when a particular action is being tried, or at the end of every turn, and such). Example:

follow the advance time rule;
follow the appraisal rulebook;

Like "number" or "text", "rule" and "rulebook" are kinds of value built into Inform: "the blossom rule" is a value whose kind is "rule", whereas "the every turn rules" is a value whose kind is "rulebook". In fact, Inform considers a rulebook to be a special case of a rule, so that whenever a rule is required it is legal to name a rulebook instead, but not vice versa. The "follow" phrase here...

Instead of switching on the machine, follow the appraisal rules.

...expects to be applied to a value of kind "rule"; "the appraisal rules" is in fact a rulebook, but since that counts as a rule the phrase makes sense to Inform. To follow a rulebook means to run through all its rules in turn, stopping when one rule reaches an outcome; to follow a single rule means just that one, of course.

When created, a rulebook starts out with no rules in it - in this example, of course, we quickly defined a couple of rules to go into it. But it's often the case in Inform that a rulebook exists without ever being stocked up, especially if the rulebook is for some obscure purpose never needed. The built-in adjectives "empty" and "non-empty", applied to a rulebook, test whether any rule is present or not.

arrow-up.png Start of Chapter 19: Rulebooks
arrow-left.png Back to §19.7. The preamble of a rule
arrow-right.png Onward to §19.9. Basis of a rulebook

Novice mode that prefaces every prompt with a list of possible commands the player could try, and highlights every important word used, to alert players to interactive items in the scenery.

***ExampleIn Fire or in Flood
A BURN command; flammable objects which light other items in their vicinity and can burn for different periods of time; the possibility of having parts or contents of a flaming item which survive being burnt.

****ExamplePatient Zero
People who wander around the map performing various errands, and in the process spread a disease which only the player can eradicate.