![]() | Chapter 18: Rulebooks | ![]() ![]() |
18.7. New rulebooks |
Creating a new rulebook is also straightforward, as we see in the following modest example game:
"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 then 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 ...", which is the first of several phrases allowing us to use rules whenever we want to (rather than simply at predetermined times such as when a particular action is being tried, or at the end of every turn, and such).
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.
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.
| ![]() ![]() ![]() 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. |
|
Previous | Contents | Next |