It's fairly common that we want to be able to refer to a container in terms of what it has in it: a bottle of wine, a salt shaker, a chicken sandwich. The player is free to remove the contents again, and the object will go back to using its usual name:
"Cinco"
Cinco de Mayo Fundraiser is a room.
The taco shell is an edible thing in the Fundraiser. It is a portable container. It has carrying capacity 1.
Understand "[something related by containment] taco" as the taco.
Rule for printing the name of the taco shell while not inserting or removing:
if the taco contains something (called filling), say "[filling] taco";
otherwise say "taco shell";
omit contents in listing.
The player carries shredded beef. It is edible.
The taking action has an object called source (matched as "from").
Setting action variables for taking:
now source is the holder of the noun.
Report taking something from the taco shell:
say "You gingerly pick [the noun] out of the taco shell." instead.
Test me with "x taco / put shredded beef in taco / get taco / i / x shredded beef taco / get shredded beef / x shredded beef taco".
By default, when something is not present, Inform does not allow a player to refer to it. But there are times when we might like to acknowledge that the thing mentioned in a command does exist somewhere in the game; it just happens not to be on hand right now.
One way to do this is to make an object that appears everywhere and responds to the name of its owner only when the owner itself is not in view.
"Puncak Jaya"
A ghost is a kind of person. A man-ghost is a kind of ghost. A man-ghost is always male. A woman-ghost is a kind of ghost. A woman-ghost is always female.
We make the ghost a person rather than some other kind of thing so that it will be able to respond to commands such as KISS BOB or (even trickier) BOB, JUMP: if Inform did not recognize the ghost as an animate creature, it would not accept such input.
Representation relates one ghost to one person. The verb to represent means the representation relation.
One man-ghost represents every man. One woman-ghost represents every woman.
This is, technically, an assembly -- except instead of saying that every device has a button part, or that there are three daffodils in every garden room, the assembly is based on a non-physical relation that we just designed.
Based on the "representation" relation, we now devise a conditional relation that applies only when the represented thing is not itself in view:
Indication relates a ghost (called X) to a person (called Y) when X represents Y and Y is not visible.
Understand "[something related by indication]" as a ghost.
When play begins:
now every ghost is in the concept-repository.
Instead of doing something to a ghost:
say "You seem to have left [a random person which is represented by the noun] behind."
Instead of doing something when the second noun is a ghost:
say "You seem to have left [a random person which is represented by the second noun] behind."
The concept-repository is an open unopenable transparent container. It is part of the air. The air is a backdrop. It is everywhere.
Base of Puncak Jaya is a room. Temple, Kippax, and Huizenga are men in Base. Peak of Puncak Jaya is above Base of Puncak Jaya.
Test me with "x kippax / up / x kippax / kiss kippax / kippax, hello".
Further complications of this example might require that the player meet a character before being able to refer to him or her.
Here we expand on the simple examples When? and Whence?; this time we want the player to be able to refer to doors by their directions, as in "the west door" when the door in question does in fact lead west.
"Whither?"
The temporal vortex is an open door. It is west of Yesterday and east of Today.
The initial appearance of a door is usually "Nearby [an item described] leads [if the other side of the item described is visited][direction of the item described from the location] to [other side of the item described][otherwise][direction of the item described from the location][end if]."
Direction-relevance relates a door (called X) to a direction (called Y) when the direction of X from the location is Y. The verb to be directionally-relevant to means the direction-relevance relation.
Understand "[something related by direction-relevance] door" as a door.
As an added touch, we respond also to the case where the player postulates a door in some direction when there is no such thing at the moment:
Rule for printing a parser error when the player's command includes "[non-door direction] door":
say "There is no door in that direction." instead.
Definition: a direction (called direction D) is non-door:
let the target be the room-or-door direction D from the location;
if the target is a door:
no;
yes;
Test me with "examine west door / x east door / w / x w door / x e door / tie me to the west door / tie the west door to me / push the west door east / push the east door west".
We start by creating a camera and a photograph object. As usual when we want to have a kind of object that can be dispensed in bulk, we start off with a bunch of identical instances of the object out of play (in this case, kept in an out-of-play container called "film roll"); we can then move them into play and give them characteristics when they're needed.
Each photograph can depict exactly one thing -- we're assuming that the player is not a landscape photographer here -- so we create a relation to indicate what is shown by each photograph. We'll then use that relation to determine how photographs are described, named, and parsed:
"Claims Adjustment"
A photograph is a kind of thing. 36 photographs are in the film roll.
Appearance relates one thing to various photographs. The verb to be shown by means the appearance relation.
The description of a photograph is usually "It shows [a random thing which is shown by the item described]."
Understand "of [something related by reversed appearance]" as a photograph.
This allows the player to refer to any photograph by its subject: useful if we have a large number of them.
Now we create an action to let the player use the camera and generate these photograph objects:
The player carries a cheap instant camera.
Understand "photograph [something] with [camera]" as photographing. Understand "photograph [something] with [something preferably held]" as photographing. Photographing is an action applying to one visible thing and one carried thing, requiring light.
The photographing action has an object called the selected film.
Setting action variables for photographing:
let N be a random photograph in the film roll;
now the selected film is N.
Check photographing:
if the second noun is not the camera, say "You need a camera for that purpose." instead.
Check photographing:
if the noun is the camera, say "Sadly impossible." instead.
Check photographing:
if the selected film is nothing, say "You're out of film." instead.
Carry out photographing:
now the noun is shown by the selected film;
move the selected film to the player.
Report photographing:
say "Your camera instantly spits out [a selected film]."
Now we use two activities from the Activities chapter to describe the photographs to the player more elegantly:
After printing the name of a photograph (called target):
say " of [a random thing which is shown by the target]".
After printing the plural name of a photograph (called target):
let N be the holder of the target;
say " of [a list of things which are shown by photographs which are held by N]";
if the number of things which are shown by photographs which are held by N is greater than one, say " (variously)".
And finally we provide a brief scenario to give the player something to take pictures of:
The Treasure Room is a room. "Despite the fancy name, this is no more than a closet -- albeit a closet with its own special circuit on the house alarm."
The Treasure Room contains a small Degas, a Ming vase, and a collection of South African krugerrands. The player is carrying insurance forms, a first-class stamp, and a security envelope.
The description of the forms is "Completely filled out in black ink in block letters: now all you need to do is attach photographic evidence of the objects you wish to insure."
Test me with "photograph degas / i / photograph degas / i / x photograph of degas / photograph me / x photograph of me / i / photograph vase / photograph camera / photograph collection / g / i / test more".
Test more with "x photograph of collection / x photograph of krugerrands / x photograph of collection of south african krugerrands / photograph photograph of degas / x photograph of photograph of degas".