§8.4. Furniture
Most domestic furniture consists of supporters and containers of one size or another. This means that the simplest furniture needs no elaborate instructions:
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).
|
ExampleTamed
Examples of a container and a supporter that can be entered, as well as nested rooms.
|
|
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:
"Tamed"
The Center Ring is a room. The cage is in the Center Ring. A lion is an animal in the cage. The cage is enterable, openable, transparent, and closed.
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:
The pedestal is in the Center Ring. It is enterable.
And in fact we can tell Inform that the player starts on the pedestal with this line:
The player is on a pedestal.
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:
Inside from the Center Ring is the Starry Vastness.
...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:
Instead of entering the magician's booth: try going inside.
Test me with "get in cage / open cage / get in cage / z / close cage / out / open cage / get on pedestal / get off / look / enter booth / out".
|
ExamplePrincess and the Pea
The player is unable to sleep on a mattress (or stack of mattresses) because the bottom one has something uncomfortable under it.
|
|
The main point here is that we need to figure out where the stack meets the floor:
"Princess and the Pea"
The Topmost Turret is a room. A mattress is a kind of supporter. A mattress is always enterable. A mattress is portable.
A large mattress is a mattress in the Turret. A medium mattress is a mattress in the Turret. A small mattress is a mattress in the Turret.
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]."
Instead of sleeping:
say "You can't sleep standing up!"
Instead of looking under a mattress, say "You scout around, but are unable to determine what's causing you this discomfort. If only your maid Winnie were here. She's very good at this."
Test me with "sleep / enter small / sleep / get up / get small / put small on medium / get on small / sleep / get up / g / get medium / put medium on large / get on small / look / sleep".
|
ExampleKiwi
Creating a raised supporter kind whose contents the player can't see or take from the ground.
|
|
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.
"Kiwi"
Section 1 - Procedure
A raised supporter is a kind of supporter.
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].";
otherwise:
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.
Definition: a thing (called target item) is out of reach:
if the player is on a supporter, no;
if the target item is on a raised supporter, yes;
no.
Now we also need to prevent the player from interacting with things that are out of reach:
Before doing something:
if the noun is out of reach or the second noun is out of reach:
say "You can't reach from down here." instead.
...or restoring things to the shelves while the player is in the wrong position...
Instead of putting something on a raised supporter when the player is not on a supporter:
say "You can't reach from down here."
And raised supporters shouldn't be searchable from the ground either:
Instead of searching or examining a raised supporter when the player is not on a supporter:
say "You can't see from down here."
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:
Disallowed-all is a truth state that varies. Disallowed-all is false.
Rule for deciding whether all includes an out of reach thing:
now disallowed-all is true;
it does not.
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.";
otherwise:
make no decision.
A first action-processing rule:
now disallowed-all is false.
Section 2 - Scenario
The Bottom of the Nursery is a room. "Ever since you ate that mysterious cake, you've been even shorter than usual."
The high shelf is a raised supporter in the Nursery. It is scenery. On the high shelf are a kiwi-green ball and a stuffed dodo.
The step-ladder is an enterable supporter in the Nursery. Understand "ladder" as the step-ladder.
Test me with "x shelf / search shelf / get dodo / get all from shelf / stand on ladder / get all from shelf / search shelf / get off / put all on shelf / get all from shelf / stand on ladder / put all on shelf".
|
ExampleCircle of Misery
Retrieving items from an airport luggage carousel is such fun, how can we resist simulating it, using a list as a ring buffer?
|
|
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.)
"Circle Of Misery"
Luggage item is a kind of thing. The blue golf bag, the leopardskin suitcase, the green rucksack and the Lufthansa shoulder-bag are luggage items.
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 circle of misery is a list of objects that varies.
When play begins:
now all the luggage items are in the carousel;
add the list of luggage items to the circle of misery.
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."
After taking a luggage item (called the bag):
remove the bag from the circle of misery, if present;
say "Taken."
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.
Instead of inserting something into the carousel, say "In recent years, the authorities have tended to frown upon depositing bags in random places at airports."
Test me with "get suitcase / get suitcase / get suitcase / get suitcase / look / get golf bag / look / get golf bag".
|
ExampleYolk of Gold
Set of drawers where the item the player seeks is always in the last drawer he opens, regardless of the order of opening.
|
|
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...
"Yolk of Gold"
The Turret is a room. "A cramped little room distinguished chiefly by the spiral staircase that descends from it. The windows look out over the rooftop."
The Rooftop is outside from the Turret.
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.
A spiral staircase leads up and out."
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."
After examining the desk for the first time, say "(Your employers were able to tell you to look for it, but not which drawer to look in. Typical.)"
A drawer is a kind of container. A drawer is always openable and closed. The description of a drawer is "The usual drawer of heavy wood, inadequately smoothed for ease of use."
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 a drawer when no drawers are explored:
now the noun is explored;
say "There is a tremendous screech, but nothing whatsoever inside, not even dust."
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."
Before opening an unexplored drawer when exactly two drawers are explored:
move the mysterious thing to the noun;
now the noun is explored.
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 looking under the desk when all drawers are explored:
say "There's nothing down there, but this doesn't come as a great surprise."
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."
Test me with "d / x case / x dress / x carpet / look under carpet / look under desk / x desk / open top drawer / close top drawer / look under desk / open bottom drawer / close bottom drawer / open middle drawer / get thing / look under carpet / look under desk / up".
|
ExampleSwigmore U.
Adding a new kind of supporter called a perch, where everything dropped lands on the floor.
|
|
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:
"Swigmore U."
Moe's Tavern is a room. The bar is an enterable supporter in Moe's. A drink is a kind of thing. On the bar is a drink called a flaming Homer.
A perch is a kind of supporter. A perch is always enterable. The stool is a perch in Moe's.
The player carries a dead field mouse and a tomacco fruit.
The sophisticated dropping rule is listed instead of the standard dropping rule in the carry out dropping rulebook.
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;
otherwise:
move the noun to the holder of the player.
Test me with "sit on stool / drop mouse / look / get up / look".
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:
The sophisticated report dropping rule is listed instead of the standard report dropping rule in the report dropping rulebook.
This is the sophisticated report dropping rule:
say "You drop [the noun] on [if the holder of the noun is a room]the ground[otherwise][the holder of the noun][end if]."
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 (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.
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:
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:
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".