Oyster Wide Shut
As we've seen in earlier examples such as "Equipment List", it is possible to vary the way Inform creates inventory listings in general (to create lists that look more like paragraphs of prose, lists divided between what the player is wearing and what he isn't, and so on). We can also use activities to alter the printing of specific objects' names and contents, as with the "omit contents in listing" feature after printing the name of something.
We may find, however, that we would like a great deal more control over Inform's printing of inventory details, not just as a special effect for a few items, but throughout the game.
We start by turning off Inform's native property writer:
This is very much like the library's standard behavior, but with the exception that "giving inventory information" or even "giving brief inventory information" are omitted. Here's how we supplant it:
Now, our property-aggregation rulebook is going to look at a given object and decide on a list of features that should be mentioned in inventory. We'll start by producing something quite similar to Inform's default behavior:
Notice that we don't need to write any rules about how to print that list of text: because Inform is printing out a list, it will automatically insert commas, spaces, and the word "and" where appropriate; and it will automatically follow the "use serial comma" option, if we have it set.
Now we're free to meddle. Let's give the player a bunch of possessions that will be listed in interesting ways in inventory:
Now suppose that we don't want the oyster to say "closed" when it's closed. Instead, we'd like it to say "clamped shut". As this is the only property the oyster will ever have, we can simply override his whole property-aggregation rulebook:
That's fine for the oyster because "clamped shut" is the only property he'll ever have. What if we'd like instead just to revise the way the sack (and only the sack) gets described as providing light?
Now the flashlight (and any other regular light sources we might add to the game) will be described as "providing light", but the sack will only be said to be gently glowing -- a bit more appropriate for its rather fainter gleam.
We might also wish to add a systematic feature across the board to include a new property in the inventory list? Let's say the player can enchant his possessions, and enchanted possessions should thereafter be listed accordingly:
Test me with "i / close oyster / i / turn on flashlight / i / take off flashlight / i / turn off flashlight / i / close sack / i / open sack / i / take all from sack / i / close sack / i / wear sack / i / enchant sack / i / open sack / put all in sack / i / close sack / i".
White sand stretches away both northeast and northwest, enclosing this attractive little bay. Gentle waves lap at the beach.
>(Testing.)
>[1] i
You are carrying:
a glowing plastic sack (open and gently glowing)
a rock
a flashlight lanyard (being worn)
an oyster
a pearl
>[2] close oyster
You close the oyster.
>[3] i
You are carrying:
a glowing plastic sack (open and gently glowing)
a rock
a flashlight lanyard (being worn)
an oyster (clamped shut)
>[4] turn on flashlight
You switch the flashlight lanyard on.
>[5] i
You are carrying:
a glowing plastic sack (open and gently glowing)
a rock
a flashlight lanyard (being worn and providing light)
an oyster (clamped shut)
>[6] take off flashlight
You take off the flashlight lanyard.
>[7] i
You are carrying:
a glowing plastic sack (open and gently glowing)
a rock
a flashlight lanyard (providing light)
an oyster (clamped shut)
>[8] turn off flashlight
You switch the flashlight lanyard off.
>[9] i
You are carrying:
a glowing plastic sack (open and gently glowing)
a rock
a flashlight lanyard
an oyster (clamped shut)
>[10] close sack
You close the glowing plastic sack.
>[11] i
You are carrying:
a glowing plastic sack (closed and gently glowing)
a rock
a flashlight lanyard
an oyster (clamped shut)
>[12] open sack
You open the glowing plastic sack.
>[13] i
You are carrying:
a glowing plastic sack (open and gently glowing)
a rock
a flashlight lanyard
an oyster (clamped shut)
>[14] take all from sack
Taken.
>[15] i
You are carrying:
a rock
a glowing plastic sack (open, empty and gently glowing)
a flashlight lanyard
an oyster (clamped shut)
>[16] close sack
You close the glowing plastic sack.
>[17] i
You are carrying:
a rock
a glowing plastic sack (closed, empty and gently glowing)
a flashlight lanyard
an oyster (clamped shut)
>[18] wear sack
You put on the glowing plastic sack.
>[19] i
You are carrying:
a rock
a glowing plastic sack (closed, empty, being worn and gently glowing)
a flashlight lanyard
an oyster (clamped shut)
>[20] enchant sack
Ding! You turn the glowing plastic sack magical.
>[21] i
You are carrying:
a rock
a glowing plastic sack (closed, empty, being worn, gently glowing and enchanted)
a flashlight lanyard
an oyster (clamped shut)
>[22] open sack
You open the glowing plastic sack.
>[23] put all in sack
rock: Done.
flashlight lanyard: Done.
oyster: Done.
>[24] i
You are carrying:
a glowing plastic sack (open, being worn, gently glowing and enchanted)
an oyster (clamped shut)
a flashlight lanyard
a rock
>[25] close sack
You close the glowing plastic sack.
>[26] i
You are carrying:
a glowing plastic sack (closed, being worn, gently glowing and enchanted)
an oyster (clamped shut)
a flashlight lanyard
a rock
Further variations are possible as well: if we used a "before printing the name…" rather than an "after printing the name…" rule, we could automatically generate lines like "an open and empty phosphorescent plastic sack", removing some of the artificiality of the parentheses.
Or we could add more logic to the rules about which properties are mentioned, so that some features of objects were mentioned in inventory only if the player was wearing the correct detection device, like so: