In recent years there has been a strong trend towards providing unique descriptions for all implemented objects. Often this is a good idea, but there are also contexts in which we may want to discourage the player from looking too closely at some things and concentrate his attention on just a few interesting ones.
The trick here is that leaving items completely undescribed leads to rather dull exchanges like this:
>x table
You see nothing special about the table.
...which can leave the player with the impression that the author was simply too lazy to describe everything. So it can be a good idea to replace that default message with a different one more appropriate to the game. For instance:
"Odin"
The House of a Mortal Farmer is a room. "Having two separate rooms, this house testifies to considerable wealth and success at agriculture."
The Bedroom is inside from the House.
A chair is a kind of supporter. A chair is always enterable.
In the House are a table, two chairs, a basket, and a hearth. On the table is a loaf of bread.
The description of a thing is usually "You give [the noun] a glance, but it is plainly beneath your attention."
Because the description is attached to a whole kind ("thing"), it is really a blanket instruction about many objects at once. More specific instructions always override less specific ones, so we can easily make exceptions. For instance, the following will work correctly:
The infant is a man in the basket. The description of the infant is "So strong and fat that you wonder whether one of your fellow gods is acquainted with the mistress of the house-- but it's no concern of yours, of course."
Test me with "x table / x chair / x infant".
We have to create a suitable action and say what it does, and to repeat what we do through all the scenery items. That needs material from subsequent chapters, but is quite ordinary Inform all the same:
"Beekeeper's Apprentice"
Studying the vicinity is an action applying to nothing.
Report studying the vicinity:
if the location does not contain something which is scenery:
say "There's little of interest in the [location]." instead;
repeat with point of interest running through scenery in the location:
say "[point of interest]: [run paragraph on]";
try examining the point of interest.
Understand "search" as studying the vicinity.
The Yard is a room.
The hive and the honey are scenery things in the Yard. The description of the hive is "The honeycombed hive is all around you, thrumming with life." The description of the honey is "Wax-sealed honey has been cached in many of the hexagonal nurseries."
Test me with "search".
The reason for this example is to show the use of saying "[run paragraph on]". It means we have output such as:
>search
hive: The honeycombed hive is all around you, thrumming with life.
honey: Wax-sealed honey has been cached in many of the hexagonal nurseries.
Without the running on, the prompts "hive:" and "honey:" would be separated from the descriptions following them, which would look a little odd.
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 "[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";
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
|
"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".
Suppose we want to add rules so that any time we examine a charred object (and most of our objects can be charred), a line about the charring is appended to the end of the object description. We could use "after examining...", but perhaps we would prefer for the sentence about the charring not to appear in its own paragraph.
This is an ideal occasion for a new activity. We look at the action index for "examining" to identify the rule that causes the old behavior (in this case, the "standard examining rule"); replace this with a new rule that calls our activity; and write our "printing the description" activity in such a way that it uses an object's description without forcing a paragraph return afterward.
Then we will use "after printing the description" to add our line about charring, and make sure that the paragraph return does occur before the prompt.
So:
"Crusoe"
Section 1 - Creating our New Activity
The fancy examining rule is listed instead of the standard examining rule in the carry out examining rules.
This instruction replaces a normal piece of the examine action, the standard examining rule, with another one of our own devising. (The replacement of the standard examining rule will be explained in more detail in the chapter on rulebooks.)
Printing the description of something is an activity.
This is the fancy examining rule:
carry out the printing the description activity with the noun;
rule succeeds.
All we have done here is enclose what is usually just a rule inside an activity. This means that we can now write before and after rules for the activity, and also add special instructions like "Rule for printing the name of something while printing the description of something" -- this may not be likely to arise often, but Inform now has the concept of "printing the description of something" as a separate context of action. Next we add the modification that lets us append to the description without a new line:
Rule for printing the description of something (called item):
if the description of the item is not "":
say "[description of item] [run paragraph on]";
otherwise:
say "You see nothing special about [the item]. [run paragraph on]".
"run paragraph on" here will mean that we do not get a paragraph break following the description, even if it ends with a period. We also insert a space, so that our follow-on comments will be properly punctuated.
After printing the description of something charred:
say "It is charred." instead.
The instead at the end of this line stops Inform for going on with any other "after printing the description of..." rules.
The standard library also has rules for printing additional text about containers and supporters with visible contents, and devices that are switched on; with this current system, we could add those as "after printing the description" rules as well, building up a complete paragraph if we wanted. But for simplicity we won't exemplify all of that here. The effects would be much the same as with the "charred" line.
Now, because we want to make sure that we always do get a paragraph break after our description, we add this rule last after all the other rules. "Last" and "first" rules are covered in more detail in the chapter on rulebooks.
Last after printing the description of something:
say paragraph break.
Section 2 - The Scenario
The Desert Isle is a room. "A pale expanse of sand, here and there developing into hillocks of grass, and a small clump of palms. The water is shallow here, and there are other islands within swimming distance -- or even wading distance, perhaps -- but none of them is any larger than your island, so it doesn't seem worth the trouble of visiting.
A few hundred feet out, the water turns darker blue, the sea floor drops away, and there is nothing to be seen all the way down to the horizon, except a couple of fluffy clouds, and an occasional bird.
The remains of your fire smolder in the stone-lined pit."
A thing can be charred or whole. A thing is usually whole. Instead of burning something: say "You hold [the noun] to the fire until it flares and chars."; now the noun is charred.
The player carries a stick. The description of the stick is "A strip of palm from the woodiest part of the leaf, about a foot and a half long."
The player carries a glass bottle and a piece of paper. The description of the paper is "A single blank sheet." In the glass bottle is a grain of sand. The glass bottle is openable and open. Instead of burning the glass bottle: say "You hold the bottle to the flame, but it grows uncomfortably warm."
Instead of burning the grain of sand: say "You drop the grain into the fire pit, where it becomes indistinguishable from all the others."; now the grain of sand is nowhere. Instead of dropping the grain of sand: now the grain of sand is nowhere; say "You return the grain of sand to its brethren."
The player's description is handled in an unusual way, and this will produce a space paragraph break there where it should not. Instead, therefore, we will add an instead for examining the player (probably a good idea anyway):
Instead of examining the player:
say "You are sunburned and there is sand in cracks you didn't know existed."
Test me with "i / x stick / x bottle / x sand / x paper / x me / burn stick / x stick / burn paper / x paper".
The "printing a description" activity may be useful for other games, and can be imported just by lifting section 1.