Suppose we want there to be some high shelves in our game, which the player can't get at unless he's standing on a prop of some kind. (This is a pretty hoary and over-used puzzle, but there may still be occasions when it becomes useful again.)
In order to resolve this, we want to set up a raised supporter kind. When something is on a raised supporter, it should be mentioned to the player only if the player is in the right position (i.e., standing on something) and otherwise omitted from the description entirely.
"Kiwi"
Section 1 - Procedure
A raised supporter is a kind of supporter.
For printing a locale paragraph about a raised supporter (called the high place):
if the player is on a supporter (called the riser):
say "Up on [the high place] (and only visible because you're on [the riser]) [is-are a list of things on the high place].";
otherwise:
say "The [high place] is above you."
Note that here we don't continue the activity because we want to completely replace the normal behavior of describing what is on supporters.
Definition: a thing (called target item) is out of reach:
if the player is on a supporter, no;
if the target item is on a raised supporter, yes;
no.
Now we also need to prevent the player from interacting with things that are out of reach:
Before doing something:
if the noun is out of reach or the second noun is out of reach:
say "You can't reach from down here." instead.
...or restoring things to the shelves while the player is in the wrong position...
Instead of putting something on a raised supporter when the player is not on a supporter:
say "You can't reach from down here."
And raised supporters shouldn't be searchable from the ground either:
Instead of searching or examining a raised supporter when the player is not on a supporter:
say "You can't see from down here."
Finally, we need to tackle the case where the player types GET ALL FROM SHELF, because we don't want to list the objects up there if the player can't even see them. We use a rule for deciding whether all includes in order to tell Inform not to consider items that can't be reached, and then we adjust the parser error so that it's a little more instructive than "There are none at all available!", which is what the response would otherwise be:
Disallowed-all is a truth state that varies. Disallowed-all is false.
Rule for deciding whether all includes an out of reach thing:
now disallowed-all is true;
it does not.
Rule for printing a parser error when the latest parser error is the nothing to do error and the player is not on a supporter:
if disallowed-all is true:
say "Whatever might be up there, you can't see or reach from down here.";
otherwise:
make no decision.
A first action-processing rule:
now disallowed-all is false.
Section 2 - Scenario
The Bottom of the Nursery is a room. "Ever since you ate that mysterious cake, you've been even shorter than usual."
The high shelf is a raised supporter in the Nursery. It is scenery. On the high shelf are a kiwi-green ball and a stuffed dodo.
The step-ladder is an enterable supporter in the Nursery. Understand "ladder" as the step-ladder.
Test me with "x shelf / search shelf / get dodo / get all from shelf / stand on ladder / get all from shelf / search shelf / get off / put all on shelf / get all from shelf / stand on ladder / put all on shelf".
In a very dense environment, we might want to offer the player room descriptions in which only the currently-interesting items are mentioned, while other objects are suppressed even if they are present. In effect, this takes the idea of scenery and makes it more flexible: different things might become background objects or foreground objects at different times during play.
There are a wide range of possible reasons to do this -- to shift the narrative emphasis, to change the mood of the game by highlighting different parts of the environment, to show the game from the perspective of different viewpoint characters -- but in the following example, our goal is to show the player only the objects that are currently useful for puzzles.
To do this, we need some notion of what puzzles are currently available and unsolved, so we make an "unsolved" adjective; we also need to know which things solve the puzzle, so we create a "resolving" relation, to indicate which objects resolve which problems.
Given that information, we can create rules about which objects in the game world are currently interesting, which are currently dull, and describe accordingly:
"Copper River"
Use scoring.
Section 1 - Procedure
Resolving relates various things to various things. The verb to resolve means the resolving relation.
Definition: a thing is interesting if it is not dull.
Definition: a person is dull:
no.
Definition: a thing is dull:
if it is unsolved, no;
if it resolves an unsolved thing, no;
yes.
Definition: a supporter is dull:
if it is unsolved, no;
if it resolves an unsolved thing, no;
if it supports an interesting thing, no;
yes.
Definition: a container is dull:
if it is unsolved, no;
if it resolves an unsolved thing, no;
if it contains an interesting thing, no;
yes.
After choosing notable locale objects:
repeat with item running through unsolved things:
set the locale priority of the item to 1.
For printing a locale paragraph about a dull thing (called item):
now the item is mentioned.
Before printing a locale paragraph about a supporter (called item):
now every dull thing on the item is mentioned.
Before printing a locale paragraph about a container (called item):
now every dull thing on the item is mentioned.
Instead of searching a supporter:
if the noun supports something interesting:
say "[A list of interesting things on the noun] [are] on [the noun]";
if the noun supports something dull:
say " (alongside [a list of dull things on the noun])";
say ".";
otherwise if the noun supports something dull:
say "There's nothing very useful here, only [a list of dull things on the noun].";
otherwise:
say "[The noun] [are] completely bare."
Instead of searching a container:
if the noun contains something interesting:
say "[A list of interesting things in the noun] [are] in [the noun]";
if the noun contains something dull:
say " (alongside [a list of dull things in the noun])";
say ".";
otherwise if the noun contains something dull:
say "There's nothing very useful here, only [a list of dull things in the noun].";
otherwise:
say "[The noun] [are] completely empty."
Before listing contents when not taking inventory: group dull things together.
Rule for grouping together dull things: say "assorted dull items".
Section 2 - Scenario World and Objects
The Kitchen is a room. "Your Aunt Fiona's kitchen looks as though it has been at the eye of a glitter storm. Fine, sparkling grit dusts every surface. The appliances are slightly askew, too, as though they hadn't quite settled after a vigorous earthquake."
The shelf is a scenery supporter in the Kitchen. On the shelf is a can of beans, a can of potato leek soup, and a tin of deflating powder.
The cabinet is a scenery container in the Kitchen. In the cabinet is a book of matches, a bottle of descaling solution, a fish hook, and a rusty knife. It is openable and closed.
The counter is a scenery supporter in the Kitchen. On the counter is an espresso machine, a blender, and a mortar. The blender and the mortar are containers. In the mortar is a pestle. Understand "countertop" as the counter.
The stove is a scenery supporter in the Kitchen. The oven is part of the stove. The oven is a closed openable container.
The refrigerator is a fixed in place container in the Kitchen.
Understand "fridge" as the refrigerator.
The description is "The refrigerator is a dull blue-green, and has a puffy, marshmallow texture on the outside, which means that it's no good for sticking magnets to. Aunt Fiona has never been willing to explain where she got it." The refrigerator is openable and closed.
In the refrigerator are a bottle of ice wine, a bag of carrot sticks, and an egg.
Aunt Fiona is a woman in the Kitchen. Aunt Fiona can be inflated or deflated. Aunt Fiona is inflated. "[if Aunt Fiona is inflated]Aunt Fiona stands nearby. Or perhaps 'stands' is the wrong word: she has been sort of puffed up in her own skin like a balloon, and is now propped in a corner of the room with her head lolling back[otherwise]Aunt Fiona stands -- on her own two slender legs -- at the center of the room[end if]."
Every turn when Fiona is unsolved and Fiona can see the player:
if a random chance of 1 in 3 succeeds:
say "[one of]Aunt Fiona's eyes follow you, wide and desperate, but it doesn't look like she's able to do anything[or]Aunt Fiona is still looking reproachful[or]A faint gurgling comes from Aunt Fiona[or]Aunt Fiona makes a funny croak noise[or]Aunt Fiona is still having trouble speaking. Perhaps her throat is as swollen as the rest of her[or]Aunt Fiona twitches[stopping]."
There is a thing called a salmon. Understand "fish" as the salmon. The salmon can be scaly or prepared. The salmon is scaly. The description is "[if scaly]It looks delicious, but is still covered with scales[otherwise]The salmon has been scaled and is ready to eat[end if]."
Before printing the name of the salmon when the salmon is scaly:
say "very scaly ".
Section 3 - Scenario Puzzles
Definition: Aunt Fiona is unsolved if she is inflated.
Definition: the salmon is unsolved:
if the salmon is off-stage, no;
if the salmon is scaly, yes;
no.
The deflating powder resolves Aunt Fiona.
Instead of putting the deflating powder on Aunt Fiona:
try throwing the deflating powder at Aunt Fiona.
Instead of giving the deflating powder to Aunt Fiona:
try throwing the deflating powder at Aunt Fiona.
Instead of throwing the deflating powder at Aunt Fiona:
if Aunt Fiona is inflated:
say "You toss some of the powder in Aunt Fiona's direction, and with a sudden gaseous HUFF! she returns to her usual shape and size. [paragraph break]'Well!' she says, brushing herself off. 'That was bracing!' [paragraph break]You give her an embarrassed smile, to apologize for not curing her faster.";
now Aunt Fiona is deflated;
increase the score by 2;
otherwise:
say "[one of]You throw another hefty dose of the powder at your aunt. [paragraph break]'Thank you, child,' she says, sneezing. 'But I think you've done enough now.'[or]You throw another hefty dose of the powder at your aunt. [paragraph break]'You're too kind,' she wheezes, through a cloud of glittering dust.[or]You've probably done enough with the powder.[stopping]".
Every turn when Aunt Fiona is deflated and the salmon is off-stage:
move the salmon to the counter;
say "'At least they didn't get this,' she says, producing from somewhere on her person a fresh-caught salmon. An odd pattern around its eye sockets makes it looks comically as though it wears spectacles. 'It's the Salmon of Knowledge,' she explains casually. 'We just need to scale and cook it.'"
The bottle of descaling solution resolves the salmon.
Does the player mean putting the descaling solution on the fish hook: it is unlikely.
Does the player mean putting the descaling solution on the salmon: it is very likely.
Instead of putting the bottle of descaling solution on the salmon:
if the salmon is scaly:
now the salmon is prepared;
say "With just a single squirt of the descaling solution (which confusingly has a picture of bathroom tiles on the label), you remove the scales from the salmon, leaving its pink flesh ready for preparation.";
increase the score by 2;
otherwise:
say "'Don't do that,' Aunt Fiona warns you. 'Excessive applications could damage the flesh.'"
Test me with "look / get powder / drop powder / look / look in cabinet / get powder / put powder on fiona / look / open cabinet / look in cabinet / get solution / open fridge / put solution in fridge / look / get solution / put solution on salmon / look".