| 4.5. Assemblies and body parts |
In the previous chapter, we saw that it was possible to make sub-parts of things. For instance,
The white door is in the Drawing Room. The handle is part of the white door.
creates a door with an attached handle. But what if we want to say that not just this door, but every door, should have a handle? To do this we first need to create a kind called "handle", since there will clearly need to be many handles. The solution is:
A handle is a kind of thing. A handle is part of every door.
"Every" is a loaded word and best used sparingly. A sentence like "A handle is part of every handle" would, if taken literally, mean that a handle takes forever to make and is never finished. Inform will reject this, but the moral is clear: we should think about what we are doing with "every". Another restriction is it is not safe to meddle with the three fundamental kinds "room", "container" or "supporter" by making them into assemblies, but in fact this one can be got around quite easily, like so -
A silver coin is a kind of thing. A banking room is a kind of room. Five silver coins are in every banking room.
The effect of sentences like these is to make what we might call "assemblies" instead of single things. When a banking room is created, so are five more silver coins; when a door is created, so is another handle. Such sentences act not only on items created later on in the source text, but also on all those created so far.
This is especially useful for body parts. If we would like to explore Voltaire's suggestion that history would have been very different if only Cleopatra's nose had been shorter, we will need noses:
A nose is a kind of thing. A nose is part of every person.
Something to bear in mind, though, is that in play the following may well happen:
>examine nose
Which do you mean, your nose, Antony's nose or Cleopatra's nose?
...because the player, being also a "person", is as susceptible to the invention of noses as anyone else.
Note that Inform names the otherwise nameless noses after their owners. It will always do this unless there are multiple indistinguishable things being created, as in the "five silver coins are in every banking room" example: those will all just be called "silver coin".
Something to watch out for is that if we write:
A nose is a kind of thing. A nose is part of every person. Antony and Cleopatra are people.
then we can begin talking about "Antony's nose" and "Cleopatra's nose": but it is not safe to discuss these before the sentence "A nose is part of every person" which creates them. Another pitfall is that if we then write:
Marcus Tullius Cicero is a person.
then although "Marcus Tullius Cicero's nose" and "Cicero's nose" are both valid names for the consular nose, "Marcus's nose" is not.
Suppose we want to write a game in which there are a number of chests. Each of these chests will be a container, but have a lid which is a supporter.
"U-Stor-It"
Section 1 - Assemblies and Supporters
A chest is a kind of container. A chest is always openable. A chest is usually fixed in place. A chest is usually closed. The specification of a chest is "Represents a container with a separately implemented lid; the lid is itself a supporter."
A lid is a kind of supporter. A lid is part of every chest. The specification of a lid is "A supporter attached to a chest, which can only support things when the chest is closed."
(The "specification" of a kind is not really a property, and is used instead to describe the kind in the Index. So the text of these specifications is never found in the game.) Of course, this doesn't get us very far. We will also want the game to correctly interpret variations on "open the chest" and "close the lid", redirecting actions appropriately.
Section 2 - Opening and closing
Before opening a lid which is part of a chest (called the item):
try opening the item instead.
Before closing a lid which is part of a chest (called the item):
try closing the item instead.
Before opening a chest when something is on the lid (called the obstruction) which is part of the noun:
repeat with item running through things on the obstruction
begin;
say "(first removing [the item])";
try taking the item;
end repeat;
Instead of opening a chest when something is on a lid (called the item) which is part of the noun:
say "You'd have to remove [the list of things on the item] from the lid first." instead.
Instead of looking under a lid which is part of a chest (called the item):
try opening the item.
We may also want to be able to deal with "put in" and "put on" appropriately, even if the player names the wrong part of the object:
Section 3 - Insertion and Support
Before inserting something into a lid which is part of a chest (called the item):
try inserting the noun into the item instead.
Before putting something on a chest when a lid (called the item) is part of the second noun:
try putting the noun on the item instead.
Furthermore, we don't want the player to be able to put things on the lid while the chest is open:
Before putting something on a lid which is part of an open chest (called the item):
say "(first closing [the item])";
try closing the item.
Instead of putting something on a lid which is part of an open chest (called the item):
say "[The item] would need to be closed first.";
And then we may also want a couple of rules for describing our assembled object nicely:
Section 4 - Description in Rooms
Instead of examining a closed chest when something is on a lid (called the top) which is part of the noun:
say "[The noun] is closed, and there [is-are a list of things on the top] on top.";
After printing the name of a chest (called the item) while listing contents of a room:
if a lid (called the second item) which supports something is part of the item
begin;
say " (on which [is-are a list of things on the second item])";
omit contents in listing;
end if.
Now we are free to create entire treasure rooms at a single blow:
Section 5 - U-Stor-It Facility
The U-Stor-It Facility is a room. The sea trunk, the shipping crate, and a metal box are chests in the U-Stor-It Facility. The metal box contains a sapphire, a gold coin, and a signed photograph of Babe Ruth.
Even though we have never explicitly defined it, the metal box has a "metal box's lid", which we can use at need.
The metal box's lid supports a small card. The description of the small card is "It reads, 'Back in 5 mins - Pandora.'"
Test me with "open trunk / x card / open metal box / put all in metal box / get card / put card on box".
|