25.19. Primitive Inform 6 declarations of rules

| Chapter 25: Extensions |

| 25.19. Primitive Inform 6 declarations of rules

By writing a sentence like this:

> The underground rule translates into I6 as "UNDERGROUND_R".

we create a new rule, the "underground rule", and also notify Inform that it will have no definition as I7 source text: instead, it will be provided as an I6 routine called "UNDERGROUND_R". We can define this with an Include like so:

> Include (-
> [ UNDERGROUND_R;
> if (real_location hasnt light) { RulebookSucceeds(); rtrue; }
> rfalse;
> ];
> -).

The rule should return false if it wants to make no decision, but call either RulebookSucceeds or RulebookFails and return true if it does. These routines can optionally take an argument: which will be the return value from the rulebook.

Note that UNDERGROUND_R itself has no arguments. In the case of an action based rulebook, the I6 variables noun, second and actor can be referred to, while for a value based rulebook the parameter is stored in the I6 global variable parameter_object (which is not necessarily an object, in spite of the name).

We can put this rule into a rulebook in the same way that any named rule can be:

> The underground rule is listed in the spot danger rules.

Previous | Contents | Next