| Chapter 15: Tables |

| 15.3. Corresponding entries

Continuing our example of the elements:

> Table 2.1 - Selected Elements

> Element | Symbol | Atomic number | Atomic weight
> "Hydrogen" | "H" | 1 | 1
> "Iron" | "Fe" | 26 | 56
> "Zinc" | "Zn" | 30 | 65
> "Uranium" | "U" | 92 | 238

If we want to know the atomic number of Uranium, say, it seems artificial to have to talk about the particular row number where the information happens to be. So we are also allowed to cross-reference, like so:

> the atomic number corresponding to a symbol of "Fe" in the Table of Selected Elements

This results in 26, and similarly

> the symbol corresponding to an atomic number of 26 in the Table of Selected Elements

results in "Fe". But we have to be careful:

> the element corresponding to an atomic number of 27 in the Table of Selected Elements

This is not allowed (it produces an error at run-time), because there is no row with atomic number 27 in this rather limited table. We can check this in advance with the condition:

> if there is an element corresponding to an atomic number of 27 in the Table of Standard Elements ...

Or more simply:

> if there is an atomic number of 27 in the Table of Standard Elements ...

The condition "if there is..." can be used with any reference to a table entry: for instance, "if there is a symbol in row 5 of the Table of Standard Elements" would be false, because there are only four rows.

207
| Example Dubai An elevator which connects any of 27 floors in a luxury hotel.

> 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. "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 begin; let the present level be the level corresponding to a floor of the location in the Table of Floors; change the current level of the Lift to the present level; otherwise; change the current level of the Lift to the current level of Generic Floor; end if; 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 begin; 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; change the current level of the Generic Floor to the current level of the Lift; move the player to the Generic Floor instead; end if. 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: change the current level of the Lift to 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 begin; clear the item; end repeat; repeat with item running through portable things enclosed by the Generic Floor begin; clear the item; end repeat. 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: if there is a floor corresponding to a level of the current level of the Lift in the Table of Floors begin; do nothing; otherwise; repeat with item running through things in Limbo begin; if the current level of the item is the current level of the Lift, move the item to the Generic Floor; end repeat; end if. A thing has a number called current level. To clear (item - a thing): change the current level of the item to 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 would be the Ryugyong Hotel in Pyongyang, North Korea, with its 105 floors -- if construction had ever progressed beyond the creation of the building's huge concrete shell.

Previous | Contents | Next