18.17. Two rulebooks used internally

| 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

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

Suppose we want to prevent the player from touching anything electrified -- not just as a response to TOUCH OBJECT, but at any time when the action would require contact with the object in question. "Electrified" A thing can be safe or electrified. A thing is usually safe. The Open Field is a room. "At this end of the field is a wire fence separating farm country from the government testing grounds beyond." The wire fence is an electrified thing in Open Field. It is scenery. The description of the wire fence is "Built into the fence is [a list of things which are part of the fence]." The scary box is an electrified container. It is part of wire fence. In the scary box is an alluring prize. The player carries a flashlight, a grappling hook, a very thick rubber glove, and a length of rope. The glove is wearable. This is the electrocution-wisdom rule: if the player wears the very thick rubber glove, make no decision; if the action requires a touchable noun and the noun is electrified, say "You fear touching [the noun]." instead; if the action requires a touchable second noun and the second noun is electrified, say "You fear touching [the second noun]." instead. The electrocution-wisdom rule is listed before the basic accessibility rule in the action-processing rules. Before touching the scary box: say "You can't help noticing a bright red sticker on the surface of the box." [This rule will fire even if we are not wearing the glove, because Before rules occur before basic accessibility.] Instead of opening the scary box: say "The scary box seems to be super-glued shut." [This one won't, because Instead rules occur after basic accessibility.] Test me with "touch fence / touch box / open box / wear glove / open box".

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

Previous | Contents | Next