18.3. New rules

| Chapter 18: Rulebooks |

| 18.3. New rules

Stretching a point seasonally, we might write:

> Every turn, say "The summer breeze shakes the apple-blossom."

This rule is nameless. It needs no name because it will never need to be referred to: by identifying it as an every turn rule we have already said enough to lodge it in the "every turn" rulebook. In fact, though, it is easy to create a named rule:

> This is the blossom shaking rule: say "The summer breeze shakes the apple-blossom."

The name of a rule must always end with the word "rule", for clarity's sake. (The phrasing "This is the ... rule" is used because "The ... rule" would be open to misinterpretation.)

Previously we had a rule which had no name, but belonged to a rulebook: now we have the opposite, because although the "blossom shaking rule" has a name, it has not been placed in any rulebook. That means it will probably never be applied, unless we give specific instructions for that.

Alternatively, it is possible to both name and place a rule in a single sentence:

> Every turn (this is the alternative blossom rule): say "The summer breeze shakes the apple-blossom."

Now the "alternative blossom rule" is a named rule in the "every turn" rulebook.

376
| Example Stone A soup to which the player can add ingredients, which will have different effects when the player eats. |
RB

A thing can have a rule as a property, if we like. Here we are going to allow the player to make a soup whose effects will depend on its ingredients. Each ingredient will have its own "food effect" rule, to be followed when the food is eaten. Note that there are other, slightly less cumbersome ways to do the same thing -- we will see in a few sections in the chapter on object-based rulebooks that we could make a "food effects rulebook" and then write a number of rules such as "food effects rule for carrots" or "food effects rule for the stone". Nonetheless, we demonstrate rules-as-properties here for the sake of thoroughness. So: "Stone" A food is a kind of thing that is edible. A food has a rule called the food effect. Carry out eating a food: if a food is part of the noun: repeat with item running through things which are part of the noun: if item is a food, follow the food effect of the item; follow the food effect of the noun. Report eating a food: say "You eat [the noun]. [diagnosis of the player]"; stop the action. To say diagnosis of (victim - a person): if the victim is ill: say "You are ill."; rule succeeds; otherwise: say "You are healthy. "; if the victim is awake, say "You are wide awake. "; otherwise say "You are sleepy. "; if the victim is bright-eyed, say "Your eyesight is clear. "; otherwise say "Your eyesight is dim. "; if the victim is weak, say "You are weak. "; otherwise say "You are strong. "; if the victim is hungry, say "You are hungry."; otherwise say "You are well-fed." And now to provide some particular foods: Some carrots are a food. The food effect of carrots is the bright-eye rule. This is the bright-eye rule: now the player is bright-eyed. Some potatoes are a food. The food effect of the potatoes is the sleepiness rule. This is the sleepiness rule: now the player is sleepy. The broth is a food. The indefinite article of the broth is "some". The food effect of broth is the filling rule. This is the filling rule: now the player is full. The hambone is a food. The food effect of the hambone is the heartiness rule. This is the heartiness rule: now the player is strong. Instead of eating the hambone: say "You cannot just eat a bone!" The poison ivy is a food. "Poison ivy grows nearby." The food effect of poison is the illness rule. This is the illness rule: now the player is ill. A person can be bright-eyed or blind. The player is blind. A person can be well or ill. The player is well. A person can be hungry or full. The player is full. A person can be strong or weak. The player is weak. A person can be awake or sleepy. The player is sleepy. The broth is in the kettle. The kettle is on the fire. The fire is in the Clearing. The Clearing is a room. The player carries the hambone, the potatoes, and the carrots. The ivy is in the clearing. Instead of examining the broth: if something is part of the broth, say "In the broth, [a list of things that are part of the broth] float[if exactly one thing is part of the broth]s[end if]."; otherwise say "It is just a thin broth with no other ingredients." Instead of inserting something into the broth: try inserting the noun into the holder of the broth. Instead of taking the broth: say "You cannot take the broth in your bare hands." And the following is a relatively unimportant nicety -- the Plurality extension provides some additional adjectives for handling objects with plural names, so we rely on it here: Include Plurality by Emily Short. After inserting a food which is not the broth into a container which contains the broth: now the noun is part of the broth; say "[The noun] [if the noun acts plural]sink[otherwise]sinks[end if] into [the second noun], making the broth richer." Test me with "x broth / eat hambone / put hambone in kettle / x broth / put potatoes in broth / x broth / eat carrots / eat broth / put ivy in kettle / eat ivy".

377
| Example The Crane's Leg 2 A description text generated based on the propensities of the player-character, following different rulebooks for different characters. |
RB

378
| Example Bribery A GIVE command that gets rid of Inform's default refusal message in favor of something a bit more sophisticated. |
RB

Previous | Contents | Next