RB §8.1. Bicycles, Cars and Boats

The vehicle kind in Inform refers to an object which can carry at least one person, but is small enough to fit into a single location:

In the Garden is a vehicle called the motor mower.

We can then apply different rules to a player going somewhere on foot or in the vehicle. Peugeot (a bicycle) is an easy example; No Relation (a car) adds an ignition switch to the vehicle; Straw Boater ★★ (a motorboat) gets around areas of lake where travel on foot is not just slower but impossible.

Hover ★★★ (a sci-fi "hover-bubble") changes the appearance of the landscape when it is seen from inside the vehicle.

See also

Ships, Trains and Elevators for larger conveyances

Examples

27. Peugeot

Let's say that our protagonist is about to flee . Obviously, he can't make the journey on foot; he needs transportation.

paste.png "Peugeot"

Include Rideable Vehicles by Graham Nelson.

The Lot is a room. The ten-speed bike is a rideable vehicle in the Lot.

We make the ten-speed bike a rideable vehicle because we want to say that the player is on it rather than in it. Then our other room:

Cambridge is east of the Lot.

And now we borrow from the Actions chapter to prevent travel without the proper equipment:

Instead of going to Cambridge when the player is not on the ten-speed bike:
    say "It's a long journey to Cambridge: you'll never make it on foot."

After going to Cambridge:
    say "You begin pedalling determinedly.";
    continue the action.

Test me with "e / get on ten-speed bike / e".

104. No Relation

We need to designate certain rooms as roads. Since the status of being a road will not change during play, we do this with a kind:

paste.png "No Relation"

A road is a kind of room. Definition: a room is offroad if it is not a road.

Instead of going by a vehicle (called the auto) to somewhere offroad:
    say "You can't drive [the auto] off-road."

Trafalgar Square is a road. "The Square is overlooked by a pillared statue of Admiral Lord Horatio Nelson (no relation), naval hero and convenience to pigeons since 1812."

The National Gallery is north of Trafalgar Square. The Strand is east of Trafalgar Square. The Strand is a road.

The car is a vehicle in Trafalgar Square. The ignition is a device. The ignition is part of the car. Instead of going by the car when the ignition is switched off: say "The ignition is off at the moment." Instead of switching on the car, try switching on the ignition. Instead of switching off the car, try switching off the ignition.

Test me with "get in car / n / e / turn on car / n / e / get out / w / n / s / e / get in car / turn off car / w / turn on ignition / w".

(In the course of the writing of Inform 7, much of Trafalgar Square was pedestrianised, making this example already out of date.)

A further technical note: notice "going by a vehicle" in the above rule, rather than "going by something". A rule such as "Instead of going by something..." will be matched whenever the player tries to go some direction while in an enterable object, whether or not that object is actually capable of movement. This is sometimes useful, but in this case we want the warning to apply only when the player is in a vehicle; if we added Trafalgar Square's statue bases to the scenario, we would not want

You can't drive the pedestal off-road.

So we restrict the rule to "Instead of going by a vehicle..."

49. Straw Boater ★★

Sometimes we like to give properties to kinds of thing, but not fill them in in all cases. For instance, we might have vehicles that optionally make noise, and those might have a "movement sound".

All properties have a default value, which we can find by looking in the Kinds tab of the index. This is what the property will be set to automatically, if we do not change it ourselves. In the case of a text property, that is ""; so for instance we might use our movement sound thus:

paste.png "Straw Boater"

Boathouse is a room. "A boathouse circa 1915, which -- though in poor repair -- still suggests Sunday afternoon jaunts taken by women in white gowns and men in straw hats."

North of the Boathouse is the Shallow Water. The description of Shallow Water is "Just south is the boathouse, and beyond it are trees and the marble terrace of the house above. The water deepens to the north."

North of Shallow Water is Deep Water. The description of Deep Water is "From here the boathouse has dwindled invisibly to the south, and you have a broad panorama of the shoreline, all the way down to the Skeleton Point Lighthouse in the southeast."

A vehicle has some text called the movement sound. The sailboat and the motorboat are vehicles in the Boathouse. The movement sound of the motorboat is "VRRRROOOMMMM..." Understand "boat" as the sailboat. Understand "boat" as the motorboat.

Note that we haven't given the sailboat any movement sound at all.

After going somewhere by a vehicle (called cart):
    if the movement sound of the cart is not "", say "[the movement sound of the cart][paragraph break]";
    continue the action.

Instead of exiting when the player is in a vehicle and the location is not the Boathouse:
    say "You're not dressed for a swim."

Instead of going somewhere when the player is not in a vehicle:
    say "You'd rather not try to make this journey by swimming alone."

Test me with "n / get in sailboat / n / get out / s / get in motorboat / n / n".

29. Hover ★★★

Suppose we want the player to see a modified room description when he's viewing the place from inside a vehicle. There are several conceivable ways of doing this; the example here shows a rather advanced way, but is very flexible and will let us write all sorts of special cases.

paste.png "Hover"

Use full-length room descriptions.

Emerald City is a room. "All the buildings are spires and none of them have doors." The Vast Desert is west of Emerald City. "[if the player is in a vehicle]Outside, a[otherwise]A[end if] trackless waste stretches as far as the eye can see in every direction."

The hover-bubble is a vehicle in the Emerald City. "Your hover-bubble awaits." The description is "The hover-bubble is a clear globe-shaped vehicle capable of transporting you anywhere you could walk, but faster." Understand "bubble" as the hover-bubble. The hover-bubble contains a chocolate wrapper and a parking ticket.

Here's the tricky part, which relies on material from the chapters on Activities and Rulebooks:

The container interior rule is listed before the room description body text rule in the carry out looking rules.

This is the container interior rule:
    if the actor is the player and the player is in an enterable thing (called current cage), carry out the describing the interior activity with the current cage.

Describing the interior of something is an activity.

Now we've done that, we can write a "rule for describing the interior" of something, which will print whatever we like:

Rule for describing the interior of the hover-bubble:
    say "The hover-bubble is transparent, but tints everything outside very faintly lavender."

In fact, as a special refinement, we could even say:

Rule for describing the interior of the hover-bubble when the hover-bubble contains more than one thing:
    say "The hover-bubble is transparent, but tints everything outside very faintly lavender. Beside you you can see [a list of other things in the hover-bubble]."

Definition: a thing is other if it is not the player.

Rule for listing nondescript items of the hover-bubble when the player is in the hover-bubble: do nothing.

Test me with "get in bubble / look / west / take all / look / get out / east".

And now anything that's beside us in the vehicle will be described during that first paragraph, rather than later on.

RB §8.2. Ships, Trains and Elevators

This section covers vehicles whose interior consists of at least one entire room. Moving into this room constitutes boarding: there is then some pause while it travels: moving out again disembarks at a different location. The only complication arising is how the player controls the journey (by talking to someone? by pressing buttons? by steering?).

The Unbuttoned Elevator Affair provides the simplest possible whole-room vehicle, which ferries between two fixed points. If you are at one of these, it must be the other one you want to get to, so there is no need for controls.

Dubai ★★★ is a much more elaborate elevator, with many possible destinations, chosen using buttons inside the elevator.

Empire ★★ simulates a train journey. Here there are no controls as such, but the train passes through a sequence of stops spaced apart in time, so the player chooses an exit by getting out at the right moment.

On a very large, slowish craft such as a cruise liner, we are not so much travelling in a vehicle: it's more as if we are visiting a whole building, which becomes our world for the (probably long) duration of the journey. The liner steers around in long, slow curves, changing its orientation in the water, so that (if we think of "north" as a strictly magnetic matter, anyway) north is constantly rotating: something we don't notice on board because our own reference points, provided by the ship itself, stay fixed relative to ourselves. Because of this, some ships in IF are navigated using FORE, AFT, PORT and STARBOARD directions rather than NORTH, EAST, SOUTH and WEST: see Fore ★★★.

See also

Bicycles, Cars and Boats for smaller conveyances

Examples

8. The Unbuttoned Elevator Affair

This is very simple. The interior of the elevator is a single room, but which is mapped east of both of its termini. The reverse map connection, west from the elevator, can only go to a single room, and that's what determines which floor the elevator is on.

paste.png "The Unbuttoned Elevator Affair"

UNCLE Headquarters is a room. "The steel nerve-center of the free world's battle against the Technological Hierarchy for the Removal of Undesirables and the Subjugation of Humanity. Being against technology, we have only a very simple elevator to the east."

Del Floria's Tailor Shop is a room. "Only trained anti-THRUSH agents recognise the booth in the east wall as a secret elevator."

The Secret Elevator is east of UNCLE Headquarters. The Secret Elevator is east of Del Floria's Tailor Shop.

After going to the Secret Elevator:
    say "The doors automatically close, there is a rush of motion, and they open again.";
    if UNCLE Headquarters is mapped west of the Secret Elevator, now Del Floria's Tailor Shop is mapped west of the Secret Elevator;
    otherwise now UNCLE Headquarters is mapped west of the Secret Elevator;
    continue the action.

Test me with "east / west / east / west".

145. Empire ★★

Suppose we want to have a train which, at fixed times, arrives at and leaves stations. It should be possible for the player to get on and off the train when it is stopped, but not while the train is in motion.

paste.png "Empire"

The Empire Builder Train is a room. The Train has a room called the station. The station of the Train is Seattle.

The description of the Empire Builder is "One of the (relatively) plush long-distance Amtrak trains. You're in a two-story car with toilets and a cafe at one end, not having sprung for a sleeper.

[if the station of the Train is the train]Outside the window there is rapidly-passing countryside.[otherwise]Through the windows you can see the [station of the Train] train station.[end if]"

Instead of exiting when the player is in the Train:
    if the station of the Train is the Train:
        say "The train is not stopped at a station." instead;
    otherwise:
        move the player to the station of the train instead.

Before going outside when the player is in the Train:
    try exiting instead.

Before going inside when the player is in the station of the Train:
    move the player to the Train instead.

Seattle, Edmonds, Everett, Wenatchee, and Spokane are rooms. The description of a room is usually "The scenic train station of [the location][if the location is the station of the train].

The pompously-titled Empire Builder train is pulled up here, soon to continue its journey towards Chicago[end if]."

And now our schedule for the train -- somewhat truncated, admittedly, since the full three-day journey from Seattle to Chicago is a bit long even for an ambitious example.

At 4:45 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train]!";
    now the station of the Train is the Train.

At 5:10 PM:
    now the station of the Train is Edmonds;
    if the player is in the train or the player is in the station of the train, say "The train pulls into Edmonds and comes to a stop."

At 5:17 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train], running north along the shore towards Everett.";
    now the station of the Train is the Train.

At 5:39 PM:
    now the station of the Train is Everett;
    if the player is in the train or the player is in the station of the train, say "The train arrives in scenic Everett, WA: the last stop before it turns east and heads over the mountains."

At 5:44 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train] and turns east.";
    now the station of the Train is the Train.

At 8:39 PM:
    if the player is in the train or the player is in the station of the train, say "In darkness the train rolls into Wenatchee; which is just fine, considering that there is nothing to see here at all.";
    now the station of the Train is Wenatchee.

At 8:44 PM:
    if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train] and continues east through the darkness towards Spokane.";
    now the station of the Train is the Train.

Playing this out would of course require near inhuman patience. Let's set things up so that the player at least doesn't have to wait too long for his first departure:

The time of day is 4:43 PM.

...and provide fair warning of how slowly time is elapsing.

When play begins:
    now the right hand status line is "[time of day]".

Test me with "out / in / z/ z / z / out / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / out / in / out / z / z".

Test more with "out / z/ z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z".

42. Fore ★★★

Suppose we want to understand shipboard directions, but only when the player is aboard a vessel.

paste.png "Fore"

Section 1 - Procedure

The starboard is a direction. The starboard has opposite port. Understand "s" as starboard when the location is nautical.

The port is a direction. The port has opposite starboard. Understand "p" as port when the location is nautical.

The fore is a direction. The fore has opposite aft. Understand "f" as fore when the location is nautical.

The aft is a direction. The aft has opposite fore. Understand "a" as aft when the location is nautical.

Does the player mean going a nautical direction when the location is nautical: it is very likely.

Index map with fore mapped as north. Index map with aft mapped as south. Index map with port mapped as west. Index map with starboard mapped as east.

And we can even add new ways to talk about the ways things are mapped, borrowing from the Relations chapter. The following will allow us to use "is abaft of" as well as "is aft of":

[The verb to be abaft of means the mapping aft relation.]

Now, to prevent the player from using NORTH onboard ship, or AFT on land:

A room can be nautical or earthbound. A room is usually not nautical. A direction can be nautical or earthbound. A direction is usually not nautical. Starboard, port, fore, aft, up, down, the inside and the outside are nautical.

Before going a nautical direction when the location is not nautical, say "Nautical directions can only be used on board ship."

Before going an earthbound direction when the location is nautical, say "Compass directions make no sense on board ship, but you can use [list of nautical directions] instead." instead.

Section 2 - Scenario

The Fish Room is aft of the Spirit Room. Starboard of the Fish Room is the After Powder Magazine. The Bread Room is aft of the After Powder Magazine.

The Fish Room, the Spirit Room, the Bread Room, and the After Powder Magazine are nautical.

The description of the Fish Room is "Absurd quantities of salt fish are kept here, and periodically visited by the cook or someone serving him. It is otherwise an unexceptional little chamber, so far below the waterline that there are no portholes and no external light of any kind. [paragraph break]A narrow doorway leads forward into the Spirit Room, and the After Powder Magazine is starboard."

The description of the Spirit Room is "Despite its ghostly name, this is little more than a closet down at the very navel of the ship, in which alcohol is kept: both for purifying wounds and for drinking. Under normal circumstances there is a guard posted here at every hour, lest anyone take to raiding the larder. The current absence of the guard marine strikes you as a very bad sign indeed. [paragraph break]The only way out is aft."

The description of the Bread Room is "The Bread Room is not only tiny from side to side and front to back: it is also about half the height of a proper room, and the floor slopes up very steeply with the curve of the hull. [paragraph break]What is kept here would not, on land, be dignified by the name of bread: it's hard tack, punishing to the teeth, dry on the tongue, and usually a home to weevils before half the journey is done. [paragraph break]More headroom, and access to the rest of the ship, lies fore through the After Powder Magazine."

The description of the After Powder Magazine is "Kept in near darkness because no one with any sense would bring a naked flame down here: when necessary, it can be lit with a single small lantern made of very thick glass and sealed to keep the sparks within. Sacks of powder are passed up into the higher levels of the ship by the scrubby little boys called 'powder monkeys' -- but none such are here now."

Test me with "north / aft / fore".

271. Dubai ★★★

The problem of implementing an elevator that opens onto a large number of floors often challenges novice interactive fiction authors. It also raises a fundamental design problem -- how to implement a large building in an interesting way. It is tempting to write a hotel with an elevator and innumerable tedious and identical floors just for the sake of realism; in many cases it is a better idea simply to omit any locations that contribute nothing to the story or the play of the game.

In charity, though, let us assume that the author has a legitimate reason for wanting to implement an elevator that opens onto some generic floors. We will go whole-hog, and set this in the world's tallest hotel: Burj al-Arab, Dubai.

paste.png "Dubai"

The Burj al-Arab Lobby is a room. "The 202-suite Burj al-Arab - or Tower of the Arabs - stands 321 metres (1,060 feet) high, and floats on its own man-made island. It is shaped like the sail of a boat; just crossing the private bridge to reach this place set you back $55."

(Since our budget did not run to visiting Burj al-Arab, the descriptions place implicit faith in the hotel's website.)

The Assawan Spa is a room. "Treatment rooms, hydrotherapy baths, oriental massage, stand-up solarium, sauna, steam rooms and jacuzzi, two swimming pools, squash court, two fully equipped fitness studios and an aerobics floor. To the south is a shopping area, for those who do not find exercise adequately therapeutic."

The Shopping Area is south of Assawan Spa. "In a setting that would make a poet sigh, you may enjoy the services of (among others) Bulgari, Black Pearl Caviar, Albarajeel Carpet Shop, Abdul Samed Al Qurashi (amber and Arabic perfumes), Dianoor (jewellery), and the Commercial Bank of Dubai."

The Al Falak Ballroom is a room. "A palatial, two-tiered, domed ballroom crowned with a unique crystal chandelier."

Sahn Eddar is a room. "At the base of the world's tallest atrium, the Sahn Eddar restaurant offers light fine fare and Afternoon Tea. At the center, a 32-meter water column leaps toward the roof of the atrium."

Al Mahara is a room. "After the elevator, you must take a three-minute virtual submarine voyage to reach this seafood restaurant. A magnificent oval aquarium, full of sharks, is visible from every table."

Al Iwan is a room. "Middle-eastern food in an environment of dramatic black, red, and gold."

Al Muntaha is a room. "A top-floor restaurant with a magnificent view: the name means the ultimate or the highest, suitable for a place that stands at 200 metres above the Arabian Gulf. It offers modern European cuisine; and just off to the south is the Skyview Bar."

The Skyview Bar is south of Al Muntaha. "'A wonderful location for pre- and post dinner drinks,' claims the hotel's brochure, and certainly you can't fault the view."

The Juna Lounge is a room. "Two humidors that offer one of the largest selections of the finest Havana cigars in Dubai."

The Lift is a room. "This is not a mere elevator: it is an express panoramic lift, traveling six meters a second, and capable of taking you from lobby to the rooftop restaurant in an astonishingly short time. The illuminated number above the door says [current level of the Lift] - though you can make it move by pressing a numbered button."

The Presidential Suite is a room. "Astonishingly, this is not the most elaborate or expensive of suites; there is another, the Royal, upstairs of here."

The Royal Suite is a room. "The brochure described this as 'the last word in luxury,' and you have to admit that it is certainly the last word in [italic type]something[roman type]. A vast carpet of patterned red and gold stretches from you to the sofa; beyond which, in the distance, you make out several bedrooms and bathrooms outfitted in Carrera marble. There is also, of course, a private cinema."

Table of Floors

level

floor

0

Al Mahara

1

Burj al-Arab Lobby

2

Al Iwan

3

Juna Lounge

4

Sahn Eddar

15

Al Falak Ballroom

18

Assawan Spa

24

Presidential Suite

25

Royal Suite

27

Al Muntaha

The elevator exterior is a backdrop. It is not scenery. The initial appearance of the elevator exterior is "You can enter the elevator here." It is in Generic Floor, Al Mahara, the Lobby, Al Iwan, Juna Lounge, Sahn Eddar, Al Falak, Assawan Spa, Presidential Suite, Royal Suite, and Al Muntaha.

Before entering the elevator exterior, try going inside instead.

Instead of going inside in the presence of the elevator exterior:
    if there is a level corresponding to a floor of the location in the Table of Floors:
        let the present level be the level corresponding to a floor of the location in the Table of Floors;
        now the current level of the Lift is the present level;
    otherwise:
        now the current level of the Lift is the current level of Generic Floor;
    move the player to the Lift.

The Lift has a number called current level. The current level of the Lift is 1. Instead of going up in the Lift: say "You'll have to select a specific floor; your options range from 0 to 27." Instead of going down in the Lift: try going up instead. The Lobby is outside from the Lift.

Before going outside in the Lift:
    if there is a floor corresponding to a level of the current level of the Lift in the Table of Floors:
        let the other place be the floor corresponding to a level of the current level of the Lift in the Table of Floors;
        move the player to the other place instead;
    otherwise:
        now the current level of the Generic Floor is the current level of the Lift;
        move the player to the Generic Floor instead.

The Generic Floor is a room. The Generic Floor has a number called current level. The printed name of the Generic Floor is "Floor [current level of the Generic Floor]". "A long hallway between suites, some of which run up to $15,000 a night."

Understand "push [number]" as pressing button. Understand "push [number] button" as pressing button. Understand "push button [number]" as pressing button. Pressing button is an action applying to one number.

Check pressing button:
    if the player is not in the Lift, say "You cannot control the express panoramic lift unless you are yourself inside." instead;
    if the number understood is the current level of the Lift, say "The lift pings politely and reopens its doors, since you are already on floor [number understood]." instead;
    if the number understood is greater than 27, say "There are only 27 floors." instead;
    if the number understood is less than 0, say "You cannot go below the ground floor in this elevator." instead.

Carry out pressing button:
    now the current level of the Lift is the number understood;
    say "You press button [the number understood]. The lift whirs into action and moves to the correct level."

Test me with "press 3 / in / press button 3 / look / out / in / press 27 / out / s / in / n / in / press 15 / out / in / press 18 / out / s / in / n / in / press 4 button / out".

This will all work very well, unless the player has portable objects; in that case, anything he drops on the Generic Floor will be there every time he goes back -- whether it's masquerading as Floor 6 or Floor 23. There are there are two ways round this -- (i) the cheeky way. When we drop something, the unobtrusive yet ever-vigilant maids pick it up and take it down to the Foyer's lost property office; and (ii) the super-duper way, in which things are moved out of play but with their floor numbers remembered, so that the scenario can be reconstructed each time. (i) is probably in fact the more true-to-life, considering the hotel's boasts about its service, but we will demonstrate both methods.

Here is the version with vigilant maids:

paste.png The player carries a shopping bag. In the bag are a diamond necklace, a small rug, and a jar of caviar.

Carry out pressing button:
    now every portable thing enclosed by the Generic Floor is in the Office.

The Office is south of the Lobby. "Here the maids collect everything abandoned by careless guests." The printed name of the Office is "Lost and Found Office".

Test maids with "in / press 6 / out / drop all / in / out / in / press 23 / out / in / press 1 / out / s / get all".

Notice that we tie the maid service to the pressing of the lift button, so that if the player just goes into the lift and comes out again, the maids will not have had a chance to clear his possessions.

Alternatively:

paste.png The player carries a shopping bag. In the bag are an evening gown, a bolero jacket, and tickets to the Wild Wadi Animal Park.

Carry out pressing button when something is in the Generic Floor:
    repeat with item running through portable things in the Generic Floor:
        clear the item;
    repeat with item running through portable things enclosed by the Generic Floor:
        clear the item.

The "enclosed by" line clears even things left on, say, small un-portable side-tables or whatever; but because we do "in" first, we make sure to move any containers or supporters undisturbed. The next bit could be more tidily incorporated into our previous "before going outside" rule, but since we are writing this code to be optionally pasted onto the end of the first bit, we'll express the rule separately:

Before going outside in the Lift when something is in Limbo:
    unless there is a floor corresponding to a level of the current level of the Lift in the Table of Floors:
        repeat with item running through things in Limbo:
            if the current level of the item is the current level of the Lift, move the item to the Generic Floor.

A thing has a number called current level.

To clear (item - a thing):
    now the current level of the item is the current level of the Lift;
    move item to Limbo.

Limbo is a room.

Test management with "get all from bag / in / press 22 / out / drop tickets / in / press 23 / out / drop gown / in / press 22 / out / get tickets / in / press 23 / out / get gown".

And now we have a situation in which the player's valuables are left untouched wherever in the hotel he happens to abandon them.

Incidentally, this example was almost set in an entirely different location: the largest hotel in the world may some day be the Ryugyong Hotel in Pyongyang, North Korea, with its 105 floors -- but for some years construction halted at the creation of the building's huge concrete shell.

RB §8.3. Animals

Animals exhibit a wide range of behaviour: much of the chapter on Other Characters applies just as well to animals as to human beings, with the exception of the material on conversation. But two examples here, both fairly simple, show how a fairly convincing domestic pet can be achieved simply by reacting to certain events going on nearby: Feline Behavior (a cat) and Today Tomorrow ★★ (a dog).

Fido provides a dog which the player can re-name at will.

For animals that we can sit on and ride - a camel or a horse, say - we may want to use the Rideable Vehicles extension by Graham Nelson, which also provides a rideable animal kind.

See also

Liveliness for pets that change what they're doing every time the player looks
Bags, Bottles, Boxes and Safes for a cat that eats food put in its container

Examples

406. Feline Behavior

Suppose we have a cat which is supposed to react to (and destroy) the most interesting thing in its environment. There are several ways we could approach this problem, but for the sake of demonstration, let's have it follow a rulebook to figure out which thing it most wants to interact with. We will then return the chosen object as "the object produced by the cat behavior rules".

paste.png "Feline Behavior"

The Kitchen is a room. The cat is an animal in the Kitchen. In the Kitchen is a bowl, a ball of wool, a newspaper. The bowl contains a quantity of cream.

The cat is wearing a silver collar. The description of the cat is "It is wearing [a list of things worn by the cat]."

The player carries a closed openable container called a bag. The bag contains catnip.

The cat behavior rules is a rulebook producing an object.

A cat behavior rule when the cat can touch the catnip:
    say "The cat frolics with the catnip until nothing remains of it.";
    rule succeeds with result catnip.

A cat behavior rule when the cat can touch the cream:
    say "The cat laps up the cream.";
    rule succeeds with result cream.

A cat behavior rule when the cat can touch the ball of wool:
    say "The cat makes the ball of wool into a useless tangle which must be discarded.";
    rule succeeds with result ball.

A cat behavior rule when the cat can touch the newspaper:
    say "The cat bats playfully at the newspaper until all the nasty boring articles are destroyed.";
    rule succeeds with result newspaper.

A cat behavior rule:
    say "The cat looks miffed at the lack of ready entertainment, and glares at you with yellow eyes as though wondering whether your pants leg is good for claw-sharpening.";
    rule fails.

Every turn:
    let the destroyed object be the object produced by the cat behavior rules;
    if the destroyed object is not nothing:
        now the destroyed object is nowhere;
        say "[line break]Good thing you have no use for [the destroyed object] yourself.[paragraph break]".

Test me with "z / z / open bag / z / z".

We include the if rule succeeded... condition here because nothing will be returned if the cat's search failed (as for instance in the result of the final rule).

Naturally, if we wanted we could equally well ask "if rule failed...".

420. Fido

Suppose we'd like to have a dog which the player is allowed to name himself. We'd like to deal correctly with both

>name the dog fido

and

>name the dog "fido"

so we'll also need to strip quotation marks out of the command. We can do this as follows:

paste.png "Fido"

The Back Yard is a room.

A dog is an animal in Back Yard. The dog has some text called the nickname. The nickname of the dog is "nothing". Understand the nickname property as describing the dog.

Rule for printing the name of the dog when the nickname of the dog is not "nothing":
    say "[nickname of the dog]"

Naming it with is an action applying to one thing and one topic. Understand "name [something] [text]" as naming it with. Check naming it with: say "You can't name that."

Instead of naming the dog with "nothing":
    now the nickname of the dog is "nothing";
    now the dog is improper-named;
    say "You revoke your choice of dog-name."

Instead of naming the dog with something:
    let N be "[the topic understood]";
    replace the text "'" in N with "";
    now the nickname of the dog is "[N]";
    now the dog is proper-named;
    say "The dog is now known as [nickname of the dog]."

Test me with "name the dog Fido / name the dog Lawrence / look / x lawrence / name Lawrence nothing / look / x lawrence".

99. Today Tomorrow ★★

Rules about concealment will affect "in the presence of", too. For instance, suppose we have a man with a pocket pet:

paste.png "Today Tomorrow"

The Temporary Employment Office is a room. "'Tomorrow's Temporary Workers - Today!' proclaims the logo over the door. The office is divided into two areas, the inner sanctum where you take calls and fiddle with the computer, and the outer area where workers take skill exams and watch inspirational videos ('Earn your way to partial benefits!', 'Vacation days and you!', 'Temping the Tomorrow Way', etc.)."

Maya is a woman in the Office. "Your coworker Maya sits at her own computer, diligently modifying all the [one of]pay rates in the database down from $9.00 an hour to $8.96[or]billing rates in the database up from $25.00 an hour to $25.04[purely at random]." She wears a trenchcoat. She carries a chihuahua. The description of Maya is "[if Maya is wearing the trenchcoat]She's wearing a trenchcoat, in a bizarre bid to keep your boss unaware of the chihuahua in her pocket. 'Because petsitters are really expensive!' she explained to you in an urgent hiss this morning over the coffeemaker. [otherwise]She looks cold. [end if]To all appearances, she is carrying [a list of unconcealed things carried by Maya]."

Maya's computer is scenery in the Employment Office. The description is "You can't see the screen from here, but she was perfectly happy to tell you what she was doing."

Rule for deciding the concealed possessions of someone (called carrier):
    if the particular possession is the chihuahua and the carrier wears the trenchcoat, yes;
    otherwise no.

Instead of eating something in the presence of the chihuahua:
    say "[The chihuahua] yips at you! Maya looks despairingly at [the noun], which is obviously inciting it."

The desk is scenery in the Office. On the desk are a multi-line telephone and a printer. The description of the printer is "Every morning, this instrument of torture spits out a list of the assignments you have to fill - professional, attractive receptionist with level three Excel certification, at $7.05 an hour; that sort of thing. You spend the ensuing three hours trying to meet its tyrannical demands." The description of the multi-line telephone is "Line three blinks urgently at you. You'll pick it up again as soon as you can remember who it was you put on hold."

The player carries a double bacon cheeseburger and a chocolate shake. Understand "milkshake" or "beverage" as the shake. The description of the cheeseburger is "A minor self-indulgence to make up for the fact that you have to work through lunch." The cheeseburger is edible. The shake is edible. The description of the shake is "It has the consistency of spackle and is no longer cold, but there is some chocolatey goodness in it still." Understand "burger" or "hamburger" as the cheeseburger. Instead of drinking the chocolate shake: try eating the shake instead.

Test me with "x maya / x cheeseburger / drink shake / eat cheeseburger".

Unless we somehow get the trenchcoat away from Maya, the chihuahua will not be in view, and will not intervene in our lunch. All very well for the player character, but not so interesting to the story... To this end, we might add an unfortunate event, courtesy of later chapters:

The time of day is 11:45 AM.

At 11:47 AM: say "Your boss pokes his head in, temporarily free of the round of conference calls that occupy all his days. 'Maya,' he says. 'Your coat?' He shakes his head, clucking sadly. 'It doesn't say professional!' But mercifully Maya manages to take it off so slowly that he doesn't glimpse her pet before her phone rings again.";
    now Maya carries the trenchcoat.

RB §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 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 also

Position Within Rooms for a box that can be positioned and used as a stepping stool
The Human Body for letting the player take different postures on furniture or on the floor
Room Descriptions for tables and other furniture whose content listing is suppressed or modified in a room description
Entering and Exiting, Sitting and Standing for making the player automatically rise from a seat before leaving the room
Clocks and Scientific Instruments for a grandfather clock
Kitchen and Bathroom for a mirror the player can look into

Examples

13. Tamed

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:

paste.png "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".

172. Princess and the Pea

The main point here is that we need to figure out where the stack meets the floor:

paste.png "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".

361. Kiwi

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.

paste.png "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".

436. 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.)

paste.png "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".

83. 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...

paste.png "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".

396. Swigmore U. ★★

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:

paste.png "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:

paste.png 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]."

58. U-Stor-It ★★★

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.

paste.png "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".

RB §8.5. Kitchen and Bathroom

Before implementing elaborate mechanisms to handle plumbing, we should pause to ask ourselves: how much of this do we need? Is it really necessary to simulate the complete set of fixtures and fittings?

This turns out to be a little tricky to do, and also rather dull to set out. The example Modern Conveniences ★★ was actually written as a demonstration of how an extension to Inform might be written to provide a general "kitchens and bathrooms service" for writers, but it contains a nice implementation well worth borrowing. The idea is to provide a "kitchen" kind of room and a "bathroom" kind of room. All kitchens created automatically contain standard kitchen appliances: fridge, freezer, sink with taps, counters, cabinets, and a stovetop with built-in oven. Similarly, all bathrooms will have sinks, baths, cabinets, and toilets, and respond to some standard interactions.

Another common feature of bathrooms is a mirror: Versailles ★★ demonstrates how to create a simple one.

Examples

75. Versailles ★★

One of the advantages of descriptions is that we can use them to pick an item randomly from a specified category. (For more on this possibility, see the Change chapter sections on randomness.)

For instance, suppose we wanted to create a mirror in which the player would see some item from the room reflected. We might write

Instead of searching the mirror:
    say "You see [a random thing in the location] reflected back at you."

This is the same as "a random thing which is in the location": phrase "in..." can be used briefly in Inform as it can in English.

But, on a little more thought, we might want to expand on this: the mirror perhaps should reflect not only things that are in the room, but anything that the player can see (even if it's on a supporter or carried by someone). So then we might instead write

Instead of searching the mirror:
    say "You see [a random visible thing] reflected back at you."

There's still a risk, though, that this will produce the response

You see the mirror reflected back at you.

because, of course, the mirror is itself visible. So instead we might write

Instead of searching the mirror:
    say "You see [a random visible thing which is not the mirror] reflected back at you."

paste.png "Versailles"

The Hall of Plywood Boards is a room. "The Hall of Mirrors is under reconstruction: it is currently a dank tunnel enlivened only by short placards about the history of the room.

As though to mock tourists such as yourself who bought their tickets without knowing this, the officials have left uncovered a single panel of mirror."

The mirror is scenery in the Hall of Plywood Boards. Understand "panel" or "panel of mirror" as the mirror. The description is "Lovingly restored to shimmering brilliance, it suggests how marvelous this room would be if you had had the good sense to arrive after the renovations were complete."

Some tourists are a person in the Hall of Plywood Boards. The tourists are scenery.

Instead of searching the mirror:
    say "You see [a random visible thing which is not the mirror] reflected back at you."

Test me with "x mirror / look in mirror / g".

A final note: we use "searching" here because Inform understands both SEARCH THING and LOOK IN THING as the searching action, and the player is most likely to type LOOK IN MIRROR in order to see the reflection there. In the absence of an example, we can discover the relationship between actions and their command vocabulary in one of two ways. A complete list of actions and the vocabulary associated with them is available in the Actions index. Alternatively, we can type ACTIONS at a prompt, followed by LOOK IN MIRROR, and get the response

[searching the mirror]
You find nothing of interest.
[searching the mirror - failed the can't search unless container or supporter rule]

...which tells us that Inform is understanding the action as "searching the mirror".

449. Modern Conveniences ★★

Suppose we want to write an extension or other portable code which defines a "kitchen" kind of room and a "bathroom" kind of room. All kitchen rooms we create in the future will automatically contain standard kitchen appliances: fridge, freezer, sink with taps, counters, cabinets, and a stovetop with built-in oven. Similarly, all bathrooms will have sinks, baths, cabinets, and toilets, and respond to some standard interactions.

We would do this with a standard assembly:

paste.png "Modern Conveniences"

Section 1 - Kitchens

A kitchen is a kind of room.

A refrigerator is a kind of container. A refrigerator is usually closed and openable. A refrigerator is usually fixed in place. A refrigerator is usually scenery. Understand "fridge" as a refrigerator.

A freezer compartment is a kind of container. A freezer compartment is usually closed and openable. A freezer compartment is part of every refrigerator.

Now: we're going to want many of the items in our kitchen to have switches, and to handle input sensibly regardless of whether the player types TURN ON STOVE or TURN ON STOVE SWITCH. (This is apparently a stove with only one burner.) For convenience, we'll define an "includes" relation:

Inclusion relates a thing (called X) to a thing (called Y) when Y is part of X. The verb to include means the inclusion relation.

A stove is a kind of supporter. It is usually scenery.
An oven is a kind of container. An oven is usually openable and closed. One oven is a part of every stove.
A switch is a kind of device. A switch is part of every stove. A switch is part of every oven.
Understand "[something related by reversed incorporation] switch" as a switch.

What follows is fairly straightforward, but notice that we are somewhat obsessively naming every rule. This is much more important in extensions (where someone else may need to manipulate our code from within their own source) than it is when we are simply composing source text for ourselves.

Setting action variables for opening a stove (this is the stove-opening rule):
    let relevant oven be a random oven which is part of the noun;
    now the noun is the relevant oven.

Setting action variables for switching on something which includes a switch (this is the redirecting switches for switching on rule):
    let relevant switch be a random switch which is part of the noun;
    now the noun is the relevant switch.

Setting action variables for switching off something which includes a switch (this is the redirecting switches for switching off rule):
    let relevant switch be a random switch which is part of the noun;
    now the noun is the relevant switch.

Before printing the name of a switch (called target) (this is the switch identification rule):
    say "[random thing which includes the target] ".

A sink is a kind of container. A sink is usually fixed in place and scenery. A tap is a kind of switch. A tap is part of every sink. Understand "faucet" or "taps" as a tap. Understand "[something related by reversed incorporation] tap/faucet/taps" as a tap.

Instead of opening a tap, try switching on the noun. Instead of closing a tap, try switching off the noun.

Report switching on a tap (this is the standard report switching taps on rule):
    say "You turn on [the noun]." instead. [since "switch on" sounds weird in this context.]

Report switching off a tap (this is the standard report switching taps off rule):
    say "You turn off [the noun]." instead.

After examining something which includes a switched on tap (called relevant tap) (this is the report flowing water rule):
    say "The water is flowing from [the relevant tap]."

A drain is a kind of container. A drain is part of every sink. Understand "plughole" as the drain. Understand "[something related by reversed incorporation] drain/plughole" as a drain.

Instead of inserting something into a drain (this is the no clogging drains rule), say "Pointless."

This is probably about as far as we want to go in a generic simulation: it is tempting to code up water, drains down which the player can lose objects, sinks that get clogged and overflow, and so on; but the more we embellish in these ways, the more likely the end result would be disruptive to individual games. For right now what we're aiming for is something simple which provides the basic interactions a player might expect in this kind of room, but which does not have any significant implications for the surrounding world model.

A particularly conservative author might even want to make it turn out that the water has been shut off and nothing flows from the taps: in the extension documentation, we might want to include a line or two of example showing how this might be done by changing or removing the relevant rules of our extension.

A cabinet is a kind of container. A cabinet is usually openable and closed. It is scenery.
    Understand "cupboard" or "cupboards" or "cabinets" as a cabinet.

A counter is a kind of supporter. It is scenery.
    Understand "countertop" as a counter.

A cabinet is in every kitchen.
A counter is in every kitchen.
A refrigerator is in every kitchen.
A sink is in every kitchen.
A stove is in every kitchen.

Section 2 - Bathrooms

A bathroom is a kind of room.

A toilet is a kind of supporter. Understand "john" as a toilet. A toilet is usually fixed in place and enterable and scenery.

A bath is a kind of container. A bath is usually a fixed in place and enterable and scenery. A tap is part of every bath. A drain is part of every bath. Understand "bathtub" or "shower" as a bath.

A sink is in every bathroom.
A toilet is in every bathroom.
A bath is in every bathroom.
A cabinet is in every bathroom.

If we were feeling particularly ambitious and inclined toward interior decoration, we could add bath mats, mirrors, plungers, toilet brushes, overhead lighting, towel racks, scented candles, boxes of facial tissue, shampoo bottles, scrubbing loofahs, etc. ad nauseam; but we'll keep it relatively simple for now. Of course, if we have a toilet, we pretty much have to accept that the player will try to make use of it:

Understand "flush [toilet]" or "use [toilet]" as a mistake ("You have no need at the moment.").

Understand "take shower" or "take bath" or "bathe" or "wash" as bathing. Bathing is an action applying to nothing.

Check bathing (this is the restrict baths to bathrooms rule):
    if the location is not a bathroom, say "This isn't the place." instead.

Check bathing (this is the block bathing rule):
    say "You haven't time for a bath." instead.

Washing is an action applying to one thing. Understand "clean [something]" or "wet [something]" or "wash [something]" as washing.

Instead of washing the player, try bathing.

Check washing (this is the restrict washing to the proximity of sinks rule):
    unless the player can touch a sink, say "This isn't the place." instead.

Check washing (this is the block washing rule):
    say "It doesn't seem worth the bother." instead.

Now we might put this to work in a short example.

One slight challenge lies in giving these assembled pieces separate descriptions. When we have an assembly that adds parts to objects, we can then talk about (for instance) "the stove's switch" elsewhere in the code. But items that have been assigned rooms are not named in the same way, so we cannot talk about "the Industrial Kitchen's stove" in our code as a way to assign it a description or special behavior. In quite a simple example, we could make the descriptions of the kind simply be the descriptions we want for the individual items:

Section 3 - An Example We Might Offer

Our Household Kitchen is a kitchen.

The Tiny Bathroom is a bathroom. It is west of Our Household Kitchen.

The description of a stove is "Scrupulously polished."

The description of a refrigerator is "It is baby blue and has the contours of a 50[']s chevy. One of these days it really will break down, but it's been serving your family faithfully since your grandmother's honeymoon."

Test me with "x refrigerator / open fridge / x freezer / look in freezer / open freezer / turn on stove / turn on oven / x oven switch / turn off oven switch / turn off stove switch / turn on taps / x sink / w / x sink / turn on sink / take bath / use toilet".

In a game that featured multiple bathrooms and kitchens, this wouldn't be enough; our author might give the stove kind (say) a description that checked its location, as in

The description of a stove is "[if in Industrial Kitchen]A massive stainless steel stove-top with six burners[otherwise]Your standard four-burner item[end if]."

or create an

Instead of examining the stove in the Industrial Kitchen: ...

sort of rule for those objects he wanted to describe specially; or he might use a when play begins rule to initialize a few things:

When play begins:
    let N be a random stove in the Industrial Kitchen;
    move the boiling pot to N;
    change the description of N to...

Or we might even (if we anticipate lots of these kinds of amendments) want to rig up something more complex that finds the descriptions of appliances in a table, rather than relying on their individual description properties. This can all be done, but it is only interesting as long as it remains genuinely labor-saving: that is, as long as the convenience of having the assembly is greater than the annoyance of writing special rules to cover for the automation. In the end, the "kitchen" and "bathroom" room types are likely to be most useful for authors who want to include the standard props but not actually make them a critical part of the game; if stoves and sinks have more of a starring role in the production, authors may be better off coding them or at the very least placing them by hand, as in

The Industrial Kitchen is a room.

Thor is a stove in the Industrial Kitchen. It supports a boiling pot.

All these quirks are things that we (as the extension author) want to think out in advance: we should ideally warn authors about possible pitfalls in using our extension (if we can think of them) and point out ways of customizing the behavior (if there are interesting ways).