Chapter 18: Rulebooks
18.17. Two rulebooks used internally

Rulebooks handle almost all of the important tasks which an Inform work of IF must carry out in order to keep play going. We have seen them used in clarifying the player's command, supplying missing ingredients, processing the action to see what should happen, responding, and so on: by this point in the documentation, it must look as if Inform uses rulebooks for everything.

This is nearly true. There is not actually a super-rulebook controlling everything. (Such a super-rulebook would need to repeat itself and never finish, something a rulebook is not allowed to do.) Instead, what happens during play looks like so:

1. Following the "when play begins" rulebook.
2. Repeating:
    2(a). Reading and parsing a command into an action;
    2(b). Following the "action processing" rulebook;
    2(c). Following the "turn sequence" rulebook.
until the game has finished.
3. Following the "when play ends" rulebook.

The command parser occasionally calls on the services of activity rulebooks to help it, but otherwise gets on with its job in ways that we do not "see" as Inform 7 users. The rest of what happens involves rulebooks, and in particular two important beneath-the-surface rulebooks: action processing and the turn sequence.

The action processing rules are used whenever an action must be tried, by whoever tries it. This usually happens in response to player commands, but not always: it might happen because of a "try...", and it can certainly interrupt an existing action.

The turn sequence rules are used at the end of each turn, and include housekeeping as well as timekeeping. They consult the "every turn" rulebook, and advance the time of day, among other useful tasks.

In general, we should only modify the operation of these two crucial rulebooks as a last resort. Play can evidently fall to pieces if they cease to work normally.


397
* Example  Timeless
A set of actions which do not take any game time at all.

RB

In a game with tight timing, it is sometimes friendliest to the player to let him LOOK and EXAMINE as much as necessary without being penalized.

"Timeless"

Examining something is acting fast. Looking is acting fast.

Now we need a rule which, just at the right moment, stops the turn sequence rulebook in the cast of our new fast-acting actions:

The take visual actions out of world rule is listed before the every turn stage rule in the turn sequence rules.

This is the take visual actions out of world rule: if acting fast, rule succeeds.

Thus the rest of the turn sequence rulebook is omitted for looking or examining: in effect, they become out-of-world actions like "saving the game". If we wanted to add, say, taking inventory to the list of instant activities, we would just need to define it as acting fast, too.

Now the scenario for testing:

When play begins:
    say "You are cornered by a pack of zombie wolves, armed only with a torch and a pair of pinking shears. This may be your last moment on earth, unless you can think fast!"

Cleft is a room. "You're backed into a cleft in the granite: behind you are only steep, high faces of stone, and before you a narrow passage."

The plural of zombie wolf is zombie wolves. A zombie wolf is a kind of animal. Four zombie wolves are in Cleft.

Rule for writing a paragraph about zombie wolves:
    say "The good news is that there isn't much space in which for the zombie wolves to attack.";
    now every zombie wolf is mentioned.

A steep high face of stone is scenery in Cleft. Understand "rock" as the stone. The description is "Now that you look more closely, there appear to be pitons driven into the rock."

Some pitons are part of the stone. The description of the pitons is "It looks as though someone else has made this ascent before."

Instead of climbing the stone, try going up. Instead of climbing the pitons, try going up.

Above the Cleft is Clifftop.

Every turn when the location is Cleft:
    say "Alas, your time has run out. The alpha wolf springs--";
    end the story.

Every turn when the location is Clifftop:
    say "After a breathless climb, you emerge at last onto the open clifftop.";
    end the story finally.

Test me with "x me / x stone / x pitons / climb pitons".

398
* Example  Electrified
Adding a rule before the basic accessibility rule that will prevent the player from touching electrified objects under the wrong circumstances.

RB
399
** Example  Escape from the Seraglio
Replacing the usual response to TAKE ALL so that instead of output such as "grapes: Taken. orange: Taken.", Inform produces variable responses in place of "grapes:".

RB
400
** Example  Endurance
Giving different actions a range of durations using a time allotment rulebook.

RB


PreviousContentsNext