6.7. Inventory

| Chapter 6: Commands |

| 6.7. Inventory

Occasionally we would like to change the way the name of something is printed as part of our inventory, and we can do this with a printing the name rule such as

> Rule for printing the name of the dead rat while taking inventory:
> say "dead rat (at arm's length)"

There are also several possibilities for redesigning the inventory list as a whole. INVENTORY listing with separate carried and worn items shows how to divide an inventory list into two parts, a "You are carrying: " section and a "You are wearing: " section. Equipment List goes further, and shows how we might use Inform's specialized listing functions to create a variety of differently formatted inventories.

Sometimes the way Inform by default lists properties such as "(closed)" or "(open but empty)" isn't quite what we want. Oyster Wide Shut offers a flexible alternative to the standard behavior, allowing finer control over which properties are listed and how they are described.

Trying Taking Manhattan replaces the inventory behavior for other characters: instead of silently looking through their possessions (but not describing them to the player), they now describe to the player what they're carrying and wearing.

177
| Example Equipment List Overview of all the phrase options associated with listing, and examples of how to change the inventory list into some other standard formats. |
WI

Most of the phrase options above are relatively self-explanatory; a few are less so. Here is an overview: "With newlines" tells Inform to put a new line before each listed object. Indented tells it to indent contents of objects, when listing these. "Giving inventory information" means to append information such as (closed) or (being worn) to objects. "As a sentence" means to put "and" before the last object and commas between them; this is usually not used in conjunction with newline listing. "As a sentence" obeys whatever conventions about the use of the serial comma we may have established with the "Use serial comma" option. "Including contents" means to list the contents of open or transparent containers and all supporters, whereas including all contents means to list the contents of all containers, even opaque closed ones. "Tersely", perhaps unexpectedly, puts parentheses around objects listed as the contents of other objects. "Giving brief inventory information" omits most of the inventory tags, such as "(open)" and "(worn)", but does list "(closed)" for closed containers which might not otherwise be obviously openable. "Using the definite article" means prefixing objects with "the", if applicable, rather than "a". "Listing marked items only" means including only objects that have already been declared "marked for listing". "Prefacing with is-are" means that Inform will write "is" before the list if it contains only one item, and "are" if the list contains more than one. "Not listing concealed items" means to omit from the list anything which is scenery. Finally, "with extra indentation" means that the whole list should be indented slightly, in emulation of the default inventory listing. With this information, we can try rewriting the inventory behavior to emulate the standard or to explore alternate versions: "Equipment List" The Watery Room is a room. The player carries a snorkel and a waterproof sack. The waterproof sack contains an undersea map, a diving guide, a cup, and 500 Argentine pesos. The cup contains a worm. The player wears a swimsuit and a pair of flippers. The sack is openable and open. Inventory listing style is a kind of value. The inventory listing styles are tall, wide, curt, minimal, divided tall, and divided wide. Current inventory listing style is an inventory listing style that varies. Understand "inventory [inventory listing style]" as requesting styled inventory. Requesting styled inventory is an action applying to an inventory listing style. It is an action out of world. Carry out requesting styled inventory: now current inventory listing style is the inventory listing style understood. Report requesting styled inventory: say "Inventory listing is now set to [current inventory listing style]." We begin by emulating the standard inventory listing style: Instead of taking inventory when current inventory listing style is tall: if the number of things enclosed by the player is 0, say "You are empty-handed." instead; say "You are carrying: [line break]"; list the contents of the player, with newlines, indented, giving inventory information, including contents, with extra indentation. Here we offer the alternative of listing everything together as a paragraph: Instead of taking inventory when current inventory listing style is wide: if the number of things enclosed by the player is 0, say "You are empty-handed." instead; say "You are carrying "; list the contents of the player, giving inventory information, as a sentence, including contents; say "." This may be unsatisfactory, however. Items that are inside other items are not set off from those merely carried by the player. One way around this is to use terse listing, giving such descriptions as "a waterproof sack (in which are an undersea map, a diving guide, a cup (in which is a worm) and a 500 Argentine pesos)" as opposed to the more confusing " a waterproof sack (open), inside which are an undersea map, a diving guide, a cup, inside which is a worm and a 500 Argentine pesos". Instead of taking inventory when current inventory listing style is curt: if the number of things enclosed by the player is 0, say "You are empty-handed." instead; say "You are carrying "; list the contents of the player, tersely, giving brief inventory information, as a sentence, including contents; say "." If, using the above style, we close the sack, we will still get "(closed)" after the sack's listing. The following minimalist listing style abolishes even that nicety: Instead of taking inventory when current inventory listing style is minimal: if the number of things enclosed by the player is 0, say "You are empty-handed." instead; say "You are carrying "; list the contents of the player, tersely, as a sentence, including contents; say "." If we want to list worn things separately from carried things, we have occasion to put "listing marked items only" to work: Instead of taking inventory when the current inventory listing style is divided wide: if the number of things enclosed by the player is 0, say "You are empty-handed." instead; say "You are wearing "; now all things enclosed by the player are unmarked for listing; now all things worn by the player are marked for listing; if no things worn by the player are marked for listing, say "nothing"; otherwise list the contents of the player, as a sentence, listing marked items only; say ".[paragraph break]"; say "You are carrying "; now all things carried by the player are marked for listing; now all things worn by the player are unmarked for listing; if no things carried by the player are marked for listing, say "nothing"; otherwise list the contents of the player, as a sentence, tersely, giving brief inventory information, listing marked items only; say ".[paragraph break]". And similarly for a tall divided inventory: Instead of taking inventory when the current inventory listing style is divided tall: if the number of things enclosed by the player is 0, say "You are empty-handed." instead; if the player carries something: now all things enclosed by the player are unmarked for listing; now all things carried by the player are marked for listing; say "You are carrying: [line break]"; list the contents of the player, with newlines, indented, giving inventory information, including contents, with extra indentation, listing marked items only; if the player wears something: now all things enclosed by the player are unmarked for listing; now all things worn by the player are marked for listing; say "You are wearing: [line break]"; list the contents of the player, with newlines, indented, including contents, with extra indentation, listing marked items only. Test me with "i / inventory wide / i / inventory curt / i / close sack / i / open sack / inventory minimal / i / close sack / i / open sack / inventory divided wide / i / inventory divided tall / i / drop all / i / take all / take off swimsuit / take off flippers / i / i divided wide / i / wear swimsuit / drop all / i".

64
| Example Persephone Separate the player's inventory listing into two parts, so that it says "you are carrying..." and then (if the player is wearing anything) "You are also wearing...". |
WI

414
| Example Oyster Wide Shut Replacing Inform's default printing of properties such as "(closed)", "(open and providing light)", etc., with our own, more flexible variation. |
WI

204
| Example Trying Taking Manhattan Replacing the inventory reporting rule with another which does something slightly different. |
WI

Previous | Contents | Next