| Chapter 18: Rulebooks |

| 18.8. Action- vs object-based-rulebooks

The example of the appraisal rules, earlier in the chapter, was a rulebook whose rules were not tied to any specific action or item. We simply created rules for this rulebook by writing "An appraisal rule: ..." But most Inform rules do apply to either actions ("Instead of drinking the wine: ...") or items ("Rule for reaching inside the flask: ..."); and these two sorts of rule belong to two sorts of rulebooks. For instance, the Before, Instead and After rulebooks are based on actions, while the rulebooks associated with activities (as used by rules like "Rule for printing the name of: ...") are based on items. (As it turns out, the appraisal rulebook was action-based: it simply happened that we never specified any requirements on the action.)

We have seen that the preamble for a rule can be quite complicated, but when we strip away the optional ways to limit its applicability, give it a name, and so forth, we are left with

> ...rulebook name... [about/for/of/on/rule] [...what to apply to...]

where the square-bracketed parts are optional. If the rulebook is object-based, the "...what to apply to..." should be a description, like "a container"; if action-based, it should be an action, like "examining an open door".

1. Action-based rulebooks. We have already mentioned before, after and instead. Other action-based rulebooks include the check, carry out, and report rules; general rulebooks such as every turn rules, the procedural rules, the visibility rules, the turn sequence rules; and rules specially for dealing with the actions of other characters, such as the persuasion and unsuccessful attempt rules. So the following would all be valid:

> An every turn rule on kissing Clark:
> say "Lois glares in your direction."

> Procedural rule about someone trying taking the hat:
> ignore the can't take people's possessions rule.

> Visibility rule for looking under something:
> if the player is carrying a lit thing (called lamp)
> begin;
> say "You shine [the lamp] under [the noun]...";
> there is sufficient light;
> end if;
> there is insufficient light.

...all of which will take place on the occasions when these rulebooks would ordinarily be used, but take effect only if the action is the one specified.

The persuasion rules are dependent on the current action, but, since they will only be consulted when we ask someone to do something, it is only useful to write rules like

> Persuasion rule for asking Kent to try going: ...
> Persuasion rule: ...

and not

> Persuasion rule for taking the blue egg-cup: ...

Theoretically, the when play begins and when play ends rules could be written as things such as "When play begins rule for looking: ...", but this is not useful in any way: actions are not happening then, so such rules would never take effect.

Because action-based rulebooks tend to be the more useful of the two types of rulebook under most circumstances, this is the kind of rule created by default if we say:

> The judgment rules are a rulebook.

Having done this, we would now be allowed to write

> A judgment rule for listening to the music:
> say "Oh, Mozart is really too tedious to endure."

> A judgment rule about Kent Taylor trying kissing the player:
> say "Well, he's no Clark Gable, let's put it that way."

> Judgment rule on eating Kraft dinner:
> say "Bright orange and in no way related to real cheeses."

2. Object-parametrized rulebooks. Each activity creates three of these. For instance:

> Rule for printing the name of ...something...

and equivalently, though less elegantly,

> Rule for printing the name ...something...
> Rule for printing the name for ...something...

Each activity also generates a before and after rulebook, as we've also seen. The reaching inside and reaching outside rules are also object-based rulebooks.

We may make new object-based rulebooks in the process of making new activities, of course, but sometimes a whole new activity is overkill, since an activity produces three rulebooks (before, for, after). We can instead create a simple rulebook so:

> The flotation rules are an object-based-rulebook.

Having done this, we would be allowed to write

> A flotation rule for the cork: rule succeeds.
> A flotation rule for an inflated thing: rule succeeds.
> A flotation rule: rule fails.

And we might use the flotation rules in a circumstance like this:

> After inserting something into the well:
> consider the flotation rules for the noun;
> if the rule succeeded
> begin;
> say "[The noun] bobs on the surface.";
> otherwise;
> remove the noun from play;
> say "[The noun] sinks out of sight.";
> end if.

290
| Example Flotation Objects that can sink or float in a well, depending on their own properties and the state of the surrounding environment.

Previous | Contents | Next