Teleporter/Train Coding

Hi, in my text-adventure I’m working on, I would want the player to be able to use a teleporter or bullettrain. It’s set in a huge space-cruise ship, and the teleporter would effectively limit areas where the player would go, but also limit certain areas from the player until I wanted them to be able to go there. I tried using the Dubai Example, but I couldn’t get it to work. There will be 5 “levels” to choose from, each housing different locations. Does anyone have some simplish code for a situation like this? If worse comes worse, I’ll code new actions (like ‘Press button 4’ or ‘press button 5’), but that seems like such a hassle. Do you have any ideas?

I’m at work and don’t have time to crop together a code example at the moment. But it seems like the menus extension would probably work well here. Just have to call the specific table based on what options you want the player to have, then write the move player rules based on the menu selection.

I’ll put something together this evening if someone else doesn’t before I get to my computer. (And I’m sure they will!)

Can you be more specific about what didn’t work about the Dubai example? (Did it not compile, or not do what you want, or do you just need help knowing what to change to fit the specifics of your story, or what?)

The Dubai example doesn’t compile as it appears in the documentation because it has spaces in place of tabs at certain key places. Also there is some commentary from the author within the code that isn’t actually commented out. And there is some funkiness with line breaks it the game’s output (though this is a minor issue). If those are the only issues you are having, then here is a functioning version of the Dubai example (note, you will need to QUOTE this post and copy it from there… stupid tab characters…).

[code]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;
say “[line break][run paragraph on]”;
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;
say “[line break][run paragraph on]”;
move the player to the other place instead;
otherwise:
now the current level of the Generic Floor is the current level of the Lift;
say “[line break][run paragraph on]”;
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”. [/code]

Are you copy-pasting the code from your documentation pane into the source code pane? If you click the little square icon next to the beginning of the code instead, it’ll automatically paste it into the source code pane for you, with tabs intact and the commentary commented out. It compiles for me that way.

…I learn something new every day. Haha.

Hi, sorry I wasn’t very clear. The dubai didn’t work as I copy-pasted it, but I used the blue square and it worked fine. My problem with the dubai example was that I really only wanted 5 possible warp locations, I din’t want it to have the “general floor” levels for every other story. I wanted to have it be something like, “There must be a hundred different buttons on this warp panel. While most of them have boring names, a few stick out, like…”. But, If I kept the general floor, I suppose I could use a puzzle for finding which floors you need to go to, but I think that’s kinda a sucky idea.

I agree that that would be an annoying puzzle! It sounds like what you want to do is make the action apply to texts rather than numbers. (I sound like Clippy.) That shouldn’t be too hard; you can look at the Dubai example and change this:

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.

to this:

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

Then, whenever the pressing button rules refer to “the number understood,” you’ll change it to “the topic understood.” And you’ll need to change some of the other rules, but hopefully that gives you some ideas.

R.I.P. Clippy…

Hi Harry,

The challenge with these types of things is that it’s hard to guess the exact behavior the poster is looking for and therefore the best implementation to suggest. Based on the above quote, I coded up something which might get you started, but might not be your best solution. If you posted an example of how you would like the output to look (i.e. an imaginary transcript), we could steer you in the right direction. Also, feel free to ask if you need help understanding my code:

[code]Section - Worlds

A world is a kind of region.

Current world is a world that varies. [defaults to first world created]

Definition: a world is other if it is not the current world. [helps later]

Section - Navigating

Navigating to is an action applying to one visible thing.
Understand “navigate to [any world]” or “nav to [any world]” as navigating to.
Understand “navigate to [something]” or “nav to [something]” as navigating to. [this will help catch errors]

Check navigating to (this is the can only navigate from the bridge rule):
unless the location is the Bridge,
say “You have to be on the bridge of your ship to navigate anywhere.” instead.

[The next rule shows where the definition of “other” for worlds comes in handy:]
Check navigating to (this is the can only navigate to worlds rule):
if the noun is not a world,
say “You can only navigate to [the list of other worlds].” instead.

Check navigating to (this is the can’t navigate to same world rule):
if the noun is the current world,
say “You’re already in orbit above [the noun].” instead.

Carry out navigating to:
now the current world is the noun.

Report navigating to:
say “Navigating to [the noun]…”;
try looking.

Section - Transporting

Transporting to is an action applying to one visible thing.
Understand “transport to [any room]” or “beam to [any room]” as transporting to.
Understand “transport to [something]” or “beam to [something]” as transporting to.

Definition: a room is in range:
if it is the Bridge, decide yes;
if it is in the current world, decide yes;
decide no.

Definition: a room is other if it is not the location.

Check transporting to (this is the can’t transport to same place rule):
if the noun is the location,
say “You’re already at [the location].” instead.

Check transporting to (this is the can only transport to rooms in range rule):
unless the noun is a room and the noun is in range,
say “You can only transport to [the list of other in range rooms].” instead.

[Normally I would put the say phrase in a report rule, but since moving the player generates an automatic look, I put it here for convenience:]

Carry out transporting to:
say “Beaming to [the noun]…”;
move the player to the noun.

Section - Scenario

The Bridge is a room. “You are in orbit above [the current world]. Below [is-are the list of rooms in the current world].”
Understand “ship” as the Bridge.

Tatooine and the Fourth Moon of Yavin are worlds.

Mos Eisley Space Port is a room. “You will never find a more wretched hive of scum and villainy.”
North of Mos Eisley Space Port is the Dessert.
Mos Eisley Space Port and The Dessert are in Tatooine.

The Rebel Base is a room. “You’re surrounded by colonial vipers – confirming your belief that you are living in a startlingly derivative, sparsely implemented, and serial comma - using SciFic/Fantasy mash-up.”.
The Rebel Base is in the Fourth Moon of Yavin.

test me with “navigate to me / nav to tatooine / beam to base / transport to me / beam to mos / navigate to yavin / n / beam to base / beam to ship / nav to yavin / beam to base”.[/code]

Thank you so much for your help, everyone. This is my first time using the forums or really entering the community, and I’m shocked by how kind and pleasant all of you are! This has been a great experience and I’m excited to use it again. All your suggestions have really helped and I’m sure to use bits and pieces from all of them. Thanks superficially to Mike, not only for the coding but for the hilarious example. Hopefully, when I’m finished with the TA itself, I’ll find somewhere to post it. Thanks again.