Chapter 9: Props: Food, Clothing, Money, Toys, Books, Electronics
9.1. Food

Inform provides an either/or property called "edible" and action, "eating", for consuming edible things:

The lardy cake is edible. After eating the lardy cake, say "Sticky but delicious."

One of Inform's rules is that a person can only eat what he or she is holding - normally realistic, but it does prevent, say, eating a cherry off the tree. A procedural rule can override this: see Lollipop Guild. Delicious, Delicious Rocks, on the other hand, adds a sanity check which prevents the player from automatically taking inedible things only to be told they can't be eaten.

Inform does not normally simulate taste or digestion, but to provide foods with a range of flavours, see Would you...?; to make eating different foods affect the player differently, see Stone, or for the extreme case of poisoning foods, Candy. In MRE, hunger causes the player problems unless he regularly finds and eats food.

* See Liquids for things to drink

* See Dispensers and Supplies of Small Objects for a pizza buffet table from which the player may take all the slices he wants


365
*** Example  Lollipop Guild
Overriding the rules to allow the player to eat something without first taking it.

WI
197
*** Example  Delicious, Delicious Rocks
Adding a "sanity-check" stage to decide whether an action makes any sense, which occurs before any before rules, implicit taking, or check rules.

WI
46
* Example  Would you...?
Adding new properties to objects, and checking for their presence.

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

WI

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".

133
* Example  Candy
One of several identical candies chosen at the start of play to be poisonous.

WI
143
* Example  MRE
Hunger that eventually kills the player, and foodstuffs that can delay the inevitable by different amounts of time.

WI


PreviousContentsNext