Chapter 19: Rulebooks

§19.1. On rules; §19.2. Named rules and rulebooks; §19.3. New rules; §19.4. Listing rules explicitly; §19.5. Changing the behaviour of rules; §19.6. Sorting and indexing of rules; §19.7. The preamble of a rule; §19.8. New rulebooks; §19.9. Basis of a rulebook; §19.10. Rulebook variables; §19.11. Success and failure; §19.12. Named outcomes; §19.13. Rulebooks producing values; §19.14. Abide by; §19.15. Two rulebooks used internally; §19.16. The Laws for Sorting Rulebooks

arrow-up-left.pngContents of Writing with Inform
arrow-left.pngChapter 18: Activities
arrow-right.pngChapter 20: Advanced Text
arrow-down-right.pngIndexes of the examples

§19.1. On rules

When we open the casing and look inside the machinery of Inform, what we see are rules and rulebooks. We seldom need to know how this machinery works, but every once in a while we want to replace components, or even install new mechanisms of our own. And as we shall see, creating new rulebooks can be a neat way to tackle complicated simulations full of exceptions and special cases.

So far we have seen many rules, and the term "rulebook" has frequently but vaguely been used. Here is a summary of the rulebooks seen so far:

check taking, carry out taking, report taking
and three similar rulebooks for each of the 90 or so actions
unsuccessful attempt
reaching inside
reaching outside
does the player mean

when play begins
when play ends
every turn
when Confrontation Scene begins
when Confrontation Scene ends
and two similar rulebooks for each scene we create, if any

before printing the name of
for printing the name of
after printing the name of
and three similar rulebooks for each of the 20 or so activities

Which makes around 340 rulebooks before we even start to write. All the same, not everything in Inform belongs to a rulebook - timed events, newly-created phrases, and definitions may look vaguely as if they define rules, but they do not, so the following are not rulebooks:

At 11:10 PM: ...
To dislodge the shelf: ...
Definition: ...

arrow-up.pngStart of Chapter 19: Rulebooks
arrow-left.pngBack to Chapter 18: Activities: §18.40. Starting the virtual machine
arrow-right.pngOnward to §19.2. Named rules and rulebooks