Index: EXAMINE produces special results for a group of objects
Description: The possibility of using a [things] token opens up some interesting complications, because we may want actions on multiple items to be reported differently from actions on just one. Here we look at how to make a multiple examination command that describes groups in special ways.
Suppose that we have a game in which groups of objects can have meaning apart from their individual significance -- perhaps there are spells that can only be cast by collecting just the right items in the same place.
In this case, one of the things the player might like to be able to do is look at several items together and get a special response, different from looking at the items individually.
To make this happen, we need to do several things:
(1) we need to create a version of the EXAMINE command that can apply to multiple objects at once.
(2) we need to correct the way Inform normally deals with multiple-object commands, because we want our group description to print only one time, and we want to avoid stubs such as "pear: ... apple: ..." before or after the group description.
(3) we need to define a way for Inform to identify interesting groups and describe them.
Understand "examine [things inside] in/on [something]" or "look at [things inside] in/on [something]" as multiply-examining it from. Multiply-examining it from is an action applying to two things.
Group-description-complete is a truth state that varies.
Now for step 2, overriding Inform's usual output of names of objects:
{**}The silently announce items from multiple object lists rule is listed instead of the announce items from multiple object lists rule in the action-processing rules.
This is the silently announce items from multiple object lists rule:
unless multiply-examining or multiply-examining something from something:
We'll save our "to describe" phrase until Section 2, when we can give the game specific instructions about how to report different lists of objects.
Now, the player might also want to be able to refer to a group of item by some kind of group name, so let's add the option of creating a Table of Collective Names which will interpret these:
{**}After reading a command:
repeat through the Table of Collective Names:
let N be "[the player's command]";
let Y be relevant list entry;
while N matches the regular expression "[name-text entry]":
replace the regular expression "(.*)[name-text entry](.*)" in N with "\1[Y]\2";
A glove is a kind of thing. A glove is always wearable. Understand "glove" as a glove. The player carries a left glove and a right glove. The left glove and the right glove are gloves.
say "To anyone else it might look like a random collection of objects, but these three things -- [L with definite articles] -- constitute a mystic key known as the Left Hand of Autumn. They practically hum with power.";
We sort the lists so that regardless of how we change the rest of the code (and the order in which objects are coded), the resulting list will always be in sorted order and ready to compare with the list of items the player wants to look at. And thanks to the "Reading a command" code we wrote earlier, we can also teach the game to understand the player's references to "the left hand of autumn" as a specific collection of items.
Test me with "x apple and pear / x left and right / put pear on table / put left glove on table / x all on table / put all on table / examine all on table / get apple, twig, pear / x all on table / search table".