Inform 7 Home Page / Documentation
§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 Bicycles, Cars and Boats for smaller conveyances
Start of Chapter 8: Vehicles, Animals and Furniture | |
Back to §8.1. Bicycles, Cars and Boats | |
Onward to §8.3. Animals |
ExampleThe 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.
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.
ExampleEmpire |
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.
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:
...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".
ExampleFore |
Suppose we want to understand shipboard directions, but only when the player is aboard a vessel.
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":
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.
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."
ExampleDubai |
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.
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."
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:
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:
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.
To clear (item - a thing):
now the current level of the item is the current level of the Lift;
move item to Limbo.
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.