Chapter 18: Rulebooks
18.6. The preamble of a rule

In general, a rule looks like this:

preamble : list of one or more phrases divided by semicolons

though in a few common cases (where the preamble begins with Before, After, Instead of, Every turn, or When, and there is only one phrase in the list) the colon can be replaced with a comma. Three kinds of declaration are special, and these we can tell apart by the first word:

To ... - a new phrase: see the chapter on Phrases
At ... - something due to happen at a given time: see Time
Definition: ... - a new adjective: see Descriptions

All other declarations (that is, starting with any other word) create rules fit for going into rulebooks. The preamble can either just be a name, which is required to end with the word "rule", or it can give circumstances and have no name, or it can do both:

This is the ...name of rule...
...circumstances...
...circumstances... (this is the ...name of rule...)

The circumstances should be a sequence of the following ingredients, each of which is optional except the name of the rulebook:

first or last
followed by ...rulebook name...
followed by about or for or of or on or rule
followed by ...what to apply to...
followed by while or when ...condition...
followed by during ...a scene...

The word "first" or "last", if present, is significant: it tells Inform exactly where the new rule should be placed into its rulebook, and so overrides the normal practice of placing the rule according to how specific it is.

On the other hand, the use of any of the following:

for
of
rule about
rule for
rule on

is purely to make the text easier to read: Inform does not make any direct use of these words (except perhaps that it may help to avoid ambiguities by separating the rulebook name from what is being applied to). Thus in the rule

Instead of kissing Clark: ...

the word "instead" is the rulebook's name, while "of" is technically optional. "Instead rule about kissing Clark: ..." would work just as well.

In this whole list of possible ingredients, only the rulebook name is compulsory. We could define a rule called simply "Instead: ..." if we wanted - though its universal applicability would make it pretty disruptive, with every action stopped in its tracks.


382
* Example  We
Replacing the standard action report rules to reflect our own design.

RB

Suppose we don't like the library responses for certain actions and would prefer something else.

We could explicitly replace each report rule with "The new report dropping rule is listed instead of the standard report dropping rule...".

Another way is to slip in our replacements at the beginning of each report rulebook, and then stop the action before it got as far as calling the standard report rule. For instance, if we were designing a game in the first person plural:

"We"

Our Own Company is a room. It contains courage. The player carries names.

Test me with "z / take courage / drop names".

First report dropping rule:
    say "We casually drop [the noun]." instead.

First report taking rule:
    say "We gather [the noun] to ourselves." instead.

First report waiting rule:
    say "We talk amongst ourselves." instead.

...and so on throughout the action set.

The last (and probably much the most practical) approach to overriding library messages systematically is to use an extension designed for the purpose. Several of these are available on the Inform extensions page, including one that allows us to choose a different tense and person for the messages (for example, "She saw nothing special." rather than "You see nothing special.").

383
*** Example  Backus-Naur form for rules
The full grammar Inform uses to parse rule definitions, in a standard computer-science notation.

RB


PreviousContentsNext