§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. Persephone 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.


arrow-up.pngStart of Chapter 6: Commands
arrow-left.pngBack to §6.6. Looking Under and Hiding
arrow-right.pngOnward to §6.8. Taking, Dropping, Inserting and Putting

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

**ExampleEquipment List
Overview of all the phrase options associated with listing, and examples of how to change the inventory list into some other standard formats.

If we wanted, we might replace the rule for taking inventory as follows:

paste.png "Persephone"

Instead of taking inventory:
    say "[if the player carries something][We]['re] carrying [a list of things carried by the player][otherwise][We]['re] empty-handed";
    say "[if the player wears something]. [We]['re] wearing [a list of things worn by the player][end if]."

The Fancy Party is a room. The player carries a sword, a strawberry stem, and 20 credits worth of platinum. The player wears a sash indicating lordhood.

Test me with "i / take off sash / i / drop all / i".

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

If we wanted, we might replace the rule for taking inventory as follows:

paste.png "Persephone"

Instead of taking inventory:
    say "[if the player carries something][We]['re] carrying [a list of things carried by the player][otherwise][We]['re] empty-handed";
    say "[if the player wears something]. [We]['re] wearing [a list of things worn by the player][end if]."

The Fancy Party is a room. The player carries a sword, a strawberry stem, and 20 credits worth of platinum. The player wears a sash indicating lordhood.

Test me with "i / take off sash / i / drop all / i".

***ExampleTrying Taking Manhattan
Replacing the inventory reporting rule with another which does something slightly different.