Inform 7 Home Page / Documentation
Most domestic furniture consists of supporters and containers of one size or another. This means that the simplest furniture needs no elaborate instructions:
The candlestick is on the dining table. The dining table is fixed in place.
The silver salt cellar is on the serving trolley. The serving trolley is pushable between rooms.
The pillow is on the bed. The bed is enterable and fixed in place.
The examples below are therefore mostly ways to get around the usual restrictions on containers (that they only have one interior) and supporters (that they cannot simultaneously be containers as well).
Yolk of Gold provides a set of drawers, that is, a container with multiple interiors.
U-Stor-It provides a way to have containers with a lid which is also a supporter.
Swigmore provides a supporter which holds up the player, but has no top surface as such, and cannot hold up anything else. Kiwi demonstrates a kind of high shelf, whose objects cannot be seen or used unless the player stands on a ladder.
Princess and the Pea shows how a pile of supporters, each on top of the last, could be managed.
Tamed demonstrates furniture large enough to get inside, or on top of.
Circle of Misery demonstrates a conveyor belt, which can hold multiple items but only brings one of them within the player's reach at a time.
See Position Within Rooms for a box that can be positioned and used as a stepping stool
See The Human Body for letting the player take different postures on furniture or on the floor
See Room Descriptions for tables and other furniture whose content listing is suppressed or modified in a room description
See Entering and Exiting, Sitting and Standing for making the player automatically rise from a seat before leaving the room
See Clocks and Scientific Instruments for a grandfather clock
See Kitchen and Bathroom for a mirror the player can look into
|Start of Chapter 8: Vehicles, Animals and Furniture|
|Back to §8.3. Animals|
|Onward to §8.5. Kitchen and Bathroom|
Within a room, we might have containers and supporters that a player can enter. A chair, stool, table, dais, or pedestal would be an enterable supporter (anything we would describe a person as being "on"); a cage, hammock, or booth would be an enterable container (because we would describe the person as being "inside").
When the player is in or on something, he is able to see the rest of the contents of the room, but a note such as "(in the hammock)" or "(on the poster bed)" is added to the room title when he looks around.
Here is an example to show off the possibilities:
Notice that we made the cage transparent. Strictly speaking it is not made of transparent materials, but we can see into (or out of) a closed cage due to the gaps between the bars, so that from Inform's point of view a cage behaves much like a large sturdy glass box. (If we really wanted to make a distinction between, say, an airtight container and one with perforations, we could do so, but Inform does not model such nuances by default.) If a container is not transparent, we can see into and out of it only when it is open.
Supporters are a bit more straightforward because there is no circumstance in which they separate the player from the rest of the world:
And in fact we can tell Inform that the player starts on the pedestal with this line:
Now the player will begin there rather than just in the Center Ring.
This last bit is an entirely unnecessary bit of local color, but if we're going to keep getting into and out of the lion's cage, we ought to expect him to take notice:
Every turn when the player is in the cage:
if a random chance of 1 in 2 succeeds, say "The lion eyes you with obvious discontent.";
otherwise say "Though the lion does not move, you are aware that it is watching you closely."
Randomness is explained more completely in the chapter on Change, and every turn rules in the chapter on Time.
Finally, we might want a container whose interior is modeled as its own separate room: say, a magician's booth in which volunteers are made to disappear.
The magician's booth is a container in Center Ring. "Off to one side is a magician's booth, used in disappearing acts. The exterior is covered with painted gilt stars." The booth is enterable, open, not openable, and fixed in place.
Now we create our other location:
...which handles the case of the player typing >IN. (We will not assume by default that he wants to get into the cage with the lion, this being obviously perilous.) But we also want to make sure that the player who types >ENTER BOOTH winds up in the same place, so we should add:
Princess and the Pea
The main point here is that we need to figure out where the stack meets the floor:
Instead of sleeping when the player is on a mattress (called the bed):
let the item be the bed;
while the holder of the item is not a room:
let the item be the holder of the item;
say "You can still feel something very uncomfortable under [the item]."
Suppose we want there to be some high shelves in our game, which the player can't get at unless he's standing on a prop of some kind. (This is a pretty hoary and over-used puzzle, but there may still be occasions when it becomes useful again.)
In order to resolve this, we want to set up a raised supporter kind. When something is on a raised supporter, it should be mentioned to the player only if the player is in the right position (i.e., standing on something) and otherwise omitted from the description entirely.
For printing a locale paragraph about a raised supporter (called the high place):
if the player is on a supporter (called the riser):
say "Up on [the high place] (and only visible because you're on [the riser]) [is-are a list of things on the high place].";
say "The [high place] is above you."
Note that here we don't continue the activity because we want to completely replace the normal behavior of describing what is on supporters.
Now we also need to prevent the player from interacting with things that are out of reach:
...or restoring things to the shelves while the player is in the wrong position...
And raised supporters shouldn't be searchable from the ground either:
Finally, we need to tackle the case where the player types GET ALL FROM SHELF, because we don't want to list the objects up there if the player can't even see them. We use a rule for deciding whether all includes in order to tell Inform not to consider items that can't be reached, and then we adjust the parser error so that it's a little more instructive than "There are none at all available!", which is what the response would otherwise be:
Rule for printing a parser error when the latest parser error is the nothing to do error and the player is not on a supporter:
if disallowed-all is true:
say "Whatever might be up there, you can't see or reach from down here.";
make no decision.
Circle of Misery
The only point we need to be careful about is that the carousel is simulated twice over, in the following text: once in the built-in way that objects are inside other objects, so that the luggage items are objects contained in the carousel object; but then again by the "circle of misery" list, a ring buffer keeping track of what order things are in. We need to be careful that these two records do not fall out of synchrony: anything put into the carousel must be added to the list, anything taken out must be removed. (In fact we forbid things to be added, for simplicity's sake.)
Heathrow Baggage Claim is a room. The carousel is a container in Heathrow. "The luggage carousel, a scaly rubbered ring, does for the roundabout what Heathrow Airport does for the dream of flight: that is, turns the purest magic into the essence of boredom, only with extra stress. [if the number of entries in the circle of misery is 0]For once it stands idle. Perhaps it's broken.[otherwise]The baggage approaching you now: [the circle of misery with indefinite articles]."
The list "circle of misery" is our ring, in which entry 1 is considered to be the position of whichever bag is currently frontmost. And here it goes, round and round:
Every turn when the number of entries in the circle of misery is not 0:
rotate the circle of misery;
let the bag be entry 1 of the circle of misery;
say "The carousel trundles on, bringing [a bag] to within reach."
Before doing something with a luggage item (called the bag) which is in the carousel:
if the bag is not entry 1 of the circle of misery, say "[The bag] is maddeningly out of range. You'll have to wait for it to come round." instead.
Yolk of Gold
Suppose that for dramatic effect we would like the player to find the thing he is looking for always in the last drawer he opens...
The staircase is an open unopenable door. It is scenery. It is below the Turret and above the Library. The description is "A winding stair carved out of the single trunk of a massive tree, all in a dark wood; the outside of the stairs left unfinished with the bark still on, but the treads worn smooth by long and constant use."
The description of the Library is "Here, it seems, you have found your mark: books line both walls, a dark carpet lies on the floor, and a strange dress hangs up in a presentation case. And the thing you were told to look for, a desk with three drawers.
The cherry desk is scenery in the library. The description is "A deep, satin-lustrous cherry, with scrollwork legs and gilt touches. The years have not been kind, and it has cracked and split in several places; the finish is damaged, and where there is inlaid mother of pearl, it is beginning to come up from its bed. But it is still a sound piece, and features three drawers."
The top drawer is a drawer. The middle drawer is a drawer. The bottom drawer is a drawer. The top drawer, the middle drawer, and the bottom drawer are part of the desk. A drawer can be explored or unexplored. A drawer is usually unexplored. Instead of searching a closed drawer, try opening the noun.
After opening an unexplored drawer when exactly one drawer is explored:
now the noun is explored;
say "You struggle to open this one a bit more quietly, conscious all the time of noise... but no, it's empty. Just stands to reason."
After closing a drawer:
say "There is a racket of wood protesting against wood as you do so, which makes you wonder if you hadn't better just leave them open from now on. The unhappy owner is probably going to catch on soon enough anyway."
There is a mysterious thing. The description is "A very familiar-looking hemispherical weight of metal, goldish in tone though perhaps not made of gold. This one has a slight stickiness about the bottom surface."
Instead of opening the desk when at least one drawer is unexplored:
let the next drawer be a random unexplored drawer;
say "(starting with [the next drawer])[line break]";
try opening the next drawer.
Instead of looking under the desk when no drawers are explored:
say "You carefully survey the ground around the desk. There don't seem to be any hidden tripwires or traps to prevent you from having a look in the drawers."
Instead of looking under the desk when at least one drawer is unexplored:
say "Nothing there either. Thoroughness is a virtue with tedium as a side effect, as your mother used to say -- but they always counted her a trifle slapdash."
Instead of searching the desk when at least one drawer is unexplored:
move the mysterious thing to the player;
say "You perform a hasty, squeaky search of ";
if no drawer is explored, say "all three drawers, discovering nothing and nothing in rapid succession. But on the third drawer you ";
if exactly two drawers are unexplored, say "the remaining two drawers. There's nothing in the second, but in the third you ";
if exactly one drawer is unexplored, say "the last drawer. In it, you ";
say "turn up a promising hemispherical object.";
now all the drawers are explored.
Perhaps, just for fun, we have all the other scenery draw the player's attention back to the main point, as well.
The carpet is scenery in the Library. The description is "It is too dark for you to make out details of the antique design, which seems dimly to represent an early voyage to the moon, with ships and the travelling stars." Understand "rug" as carpet.
Instead of looking under the carpet:
if none of the drawers are explored, say "You peel up a corner of the rug gingerly; nothing results. A perfectly ordinary rug, then." instead;
if all of the drawers are explored, say "No time for that kind of nonsense. You'd better get out and away while you can." instead;
if some of the drawers are explored, say "No time for that nonsense. The desk's what you want now; what you came for won't be embedded in the flooring." instead.
The glass presentation case is transparent scenery in the Library. The description is "The case is taller than you are, framed in wood, with large panels of glass, the better to display the remarkable contents."
Instead of attacking the glass presentation case:
say "The glass pane of the presentation case shatters, throwing fine glass everywhere, including over the delicate museum-piece inside. Nor does the noise pass unnoted: only a second passes before there are footsteps in the hall, and though you make for the concealing darkness and escape of the turret, you are not swift enough. The servants are soon on you, and you are made to regret, quite painfully, this casual act of vandalism.";
end the story saying "You have lost your opportunity."
The strange dress is a wearable thing in the glass case. The description is "Not the sort of dress that anyone wears now: such elaboration would be ludicrous. It drips gold -- gilt lace, ruffles of trimmed gold, shimmering golden tracery -- dulled here and there by the sinister black of faceted jet."
Inform's default assumption is that if a player on an enterable object drops something, the dropped article winds up beside him on the same supporter or in the same container. This makes lots of sense for a dais, say, or a king-sized bed. It's a little less sensible if the enterable supporter in question is a bar stool or the like. So suppose we want to add a new kind of supporter called a perch, where everything dropped lands on the floor.
There are actually several ways of implementing this, but one of them is to reach right into the drop action and replace the "standard dropping rule" with a different one of our own invention -- like this:
This is the sophisticated dropping rule:
if the player is on a perch (called the awkward position):
let place be the holder of the awkward position;
move the noun to the place;
move the noun to the holder of the player.
Now the carry-out behavior of the dropping action has been changed, but we haven't had to interfere in the checks or reporting at all. The rest of the action works just as it always did.
Of course, maybe we do want to change the way the action is reported, to make it clearer to the player where the dropped article wound up:
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.
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."
(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.
Before opening a chest (called the box) when something is on a lid (called the obstruction) which is part of the box:
repeat with item running through things on the obstruction:
say "(first removing [the item])";
try taking 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:
Furthermore, we don't want the player to be able to put things on the lid while the chest is open:
And then we may also want a couple of rules for describing our assembled object nicely:
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:
say " (on which [is-are a list of things on the second item])";
omit contents in listing.
Now we are free to create entire treasure rooms at a single blow:
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.