6.5. Examining

| Chapter 6: Commands |

| 6.5. Examining

By default, examining an object shows its description, and - for devices - tells us whether the object is switched on or switched off.

This kind of additional information is not always what we want, so if we have a device whose on/off status we want to conceal, we may write

> The examine described devices rule is not listed in any rulebook.

On the other hand, there are times when we may want to add a similar line or two to the descriptions of other kinds of objects. Waxwork shows how to make containers and supporters automatically list everything they're holding when examined, while Crusoe allows us to append an "It is charred." sentence to the end of descriptions of things we have burned in the fire. Since it works by introducing a "printing the description" activity, Crusoe is also a good example to start from if we want to introduce more complex, flexible descriptions of items throughout our game.

Odin rewrites the "You see nothing special..." line with other text of our own, for items that otherwise do not have a description.

Finally, we may want to look at multiple things at once. The Left Hand of Autumn demonstrates how we might provide a different response for EXAMINE PAINTINGS than for examining each individually; Beekeeper's Apprentice provides a SEARCH command that will show the descriptions of all the scenery in the current location.

See Actions on Multiple Objects for an alternative EXAMINE ALL command

323
| Example Crusoe Adding a "printing the description of something" activity. |
WI

43
| Example Odin Replacing "You see nothing special..." with a different default message for looking at something nondescript. |
WI

284
| Example The Left Hand of Autumn 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. |
WI

> 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. "The Left Hand of Autumn" Section 1 - Procedure Understand "examine [things]" or "look at [things]" as multiply-examining. Multiply-examining is an action applying to one thing. 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. Carry out multiply-examining it from: try multiply-examining the noun instead. Check multiply-examining when group-description-complete is true: stop the action. Carry out multiply-examining: let L be the list of matched things; if the number of entries in L is 0, try examining the noun instead; if the number of entries in L is 1, try examining entry 1 of L instead; describe L; say line break; now group-description-complete is true. Before reading a command: now group-description-complete is false. 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: if the current item from the multiple object list is not nothing, say "[current item from the multiple object list]: [run paragraph on]". Definition: a thing is matched if it is listed in the multiple object list. 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 indexed text; let N be the player's command; let Y be indexed text; 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"; change the text of the player's command to N. Report taking something: say "You pick up [the noun]." instead. And as a bit of polish, because we'd like SEARCH TABLE to have the same effect as EXAMINE ALL ON TABLE: Understand "look on [something]" as searching. Instead of searching something which supports at least two things: let L be the list of things supported by the noun; describe L. Instead of searching something which contains at least two things: let L be the list of things contained by the noun; describe L. Section 2 - Scenario Eight-Walled Chamber is a room. "A perfectly octagonal room whose walls are tinted in various hues." The display table is a supporter in the Chamber. A twig of rowan wood is on the table. The player carries an apple and a pear. 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. Now we define a few actual lists of items: Fruit list is a list of objects which varies. Fruit list is { apple, pear }. Glove list is a list of objects which varies. Glove list is { right glove, left glove }. Arcane list is a list of objects which varies. Arcane list is { left glove, twig, pear }. To describe (L - a list of objects): sort L; if L is fruit list: say "Just a couple of fruits."; otherwise if L is glove list: say "It's a matched pair of fuzzy blue gloves."; otherwise if L is arcane list: 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."; otherwise: say "You see [L with indefinite articles]." When play begins: sort fruit list; sort glove list; sort the arcane list. 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. Table of Collective Names
> name-text | relevant list (indexed text)
> "left hand of autumn" | "[arcane list]"
> "gloves" | "[glove list]"
> "pair of gloves" | "[glove list]"
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".

68
| Example Beekeeper's Apprentice Making the SEARCH command examine all the scenery in the current location. |
WI

Previous | Contents | Next