[Inform7] Riding a rideable vehicle into another vehicle?

Hi! I’m trying to write in the ability to enter a vehicle (an elevator) while riding another vehicle, (a wheelchair). I’m trying this out with the Rideable Vehicles extension. The problem I’m hitting is that when I try to enter or exit the elevator, I’m forced to dismount the wheelchair first. If I make the wheelchair begin the game inside the elevator, I can mount the wheelchair while we are both in the elevator. But I can’t “ride” it out.

Is there any way to make this work and have a vehicle inside another vehicle? Thanks very much for any advice!

Here’s my test example:

[code]
“Lift” by lizzard

Include Rideable Vehicles by Graham Nelson.

House is a room. “North of you, there’s a busy street.”
Street is north of House. “Try looking again, then you may find an elevator.”
Concourse is down from Street. “A train concourse.”
Platform is down from Concourse. “A train platform.”

Liftlandia is a region. Platform, Concourse, and Street are in Liftlandia.

The Void is a room. In The Void is the elevator.

Every turn when the location of the player is in Liftlandia, now the elevator is in the location of the player.

The elevator is a vehicle. The description of the elevator is “A spacious elevator.”
After entering the elevator, say "You get into the elevator. "

Instead of going up when the player is not in the elevator and the location is in Liftlandia:
say “That’s fairly challenging since your wheels won’t make it up the stairs.”
After going up:
say " The elevator almost imperceptibly moves up. Time passes. You smell a lot of things, wishing you couldn’t. The doors open again.";
continue the action.
Instead of going down when the player is not in the elevator and the location is in Liftlandia:
say “Quite challenging, since your wheels won’t make it down the stairs.”
After going down:
say “The elevator almost imperceptibly moves down. Time passes. You smell a lot of things, wishing you couldn’t. The doors open again.”;
continue the action.

A snazzy powerchair is a rideable vehicle. A snazzy powerchair is in House.
The player is on a snazzy powerchair.[/code]

I think it might be possible if I somehow rewrite the implicitly pass through other barriers rule. Still thinking.

Welcome to the forum lizzard!

What you’re suggesting is probably possible, but it requires reprogramming a bunch of the underlying model for vehicles, and it might be worth thinking about whether it’s worth implementing it this way.

The first thing to mention is that vehicle behavior isn’t for the most part done by low-level magic (though making the vehicle rideable does involve some Inform 6 stuff I don’t understand). The rules involving vehicles are scattered throughout the Standard Rules, and you can find them by searching for “vehicle gone by.” Mostly, what happens is that the rules for going look to see whether the player is in a vehicle, set the “vehicle gone by” action variable when they are, and then move the vehicle instead of the player (see the “move player and vehicle” rule). There are other checks too.

So here’s a couple of things that are possibly giving you trouble:

  1. The “vehicle gone by” action variable only applies to the going action, not the entering action. So when the player enters the elevator, the rules don’t try to have them enter the elevator with the wheelchair–just to get off the wheelchair and enter the elevator. My first pass at this was to do “rules,” see that the implicitly pass through other barriers rule was causing trouble, and turn off that rule for this case–but even after doing that, the entering action will move the player and not the enclosing powerchair, since there’s no provision for entering to be done in a vehicle.

  2. The standard set going variables rule sets the vehicle gone by to a vehicle that the player is in–which means “immediately in.” So this will always be the innermost vehicle. If you want vehicles in vehicles, and you want to set the vehicle gone by to the outermost vehicle, you have to set a rule for that. (Rideable Vehicles adds some provisions to allow the vehicle gone by to be a rideable vehicle or animal, but it’s basically the same logic.)

  3. The “can’t travel in what’s not a vehicle rule” checks to see whether the holder of the player is the vehicle gone by. If the player is on the powerchair in the elevator, and we manage to get the vehicle gone by set to the elevator, this rule will block the going action, because the holder of the player will be the powerchair.

OK, so here’s something I coded to get past these problems. For number 1, I just used an Instead rule to special-case entering the elevator while on the wheelchair (this replaces your “After” rule). For number 2, I added a setting action variables rule that finds the outermost vehicular thing and sets the vehicle gone by to that. (I think it has to be a chain of vehicular things specifically–if the player is on a powerchair that is on a platform that is in a ship, the rule will stop at the powerchair.) For number 3, I changed the rule so that it checks if the holder of the player is enclosed by the vehicle gone by.

Also, I changed “if the player is in the elevator” to “if the elevator encloses the player,” because “in” means directly in so that rule wouldn’t apply when the player is on the powerchair in the elevator.

[code]“Lift” by lizzard

Include Rideable Vehicles by Graham Nelson.

House is a room. “North of you, there’s a busy street.”
Street is north of House. “Try looking again, then you may find an elevator.”
Concourse is down from Street. “A train concourse.”
Platform is down from Concourse. “A train platform.”

Liftlandia is a region. Platform, Concourse, and Street are in Liftlandia.

The Void is a room. In The Void is the elevator.

Every turn when the location of the player is in Liftlandia, now the elevator is in the location of the player.

The elevator is a vehicle. The description of the elevator is “A spacious elevator.”
Instead of entering the elevator when the player is on the powerchair:
say “You roll your chair into the elevator.”;
now the powerchair is in the elevator.

Instead of going up when the elevator does not enclose the player and the location is in Liftlandia:
say “That’s fairly challenging since your wheels won’t make it up the stairs.”
After going up:
say " The elevator almost imperceptibly moves up. Time passes. You smell a lot of things, wishing you couldn’t. The doors open again.";
continue the action.
Instead of going down when the elevator does not enclose the player and the location is in Liftlandia:
say “Quite challenging, since your wheels won’t make it down the stairs.”
After going down:
say “The elevator almost imperceptibly moves down. Time passes. You smell a lot of things, wishing you couldn’t. The doors open again.”;
continue the action.

A snazzy powerchair is a rideable vehicle. A snazzy powerchair is in House.
The player is on a snazzy powerchair.

Rule for setting action variables for going (this is the set going vehicle to the outermost vehicle rule):
let conveyance be the player;
while the conveyance is in a vehicle or the conveyance is on a rideable vehicle:
if the conveyance is in a vehicle (called the new conveyance), now the conveyance is the new conveyance;
if the conveyance is on a rideable vehicle (called the new conveyance), now the conveyance is the new conveyance;
if the conveyance is not the player, now the vehicle gone by is the conveyance.

Check an actor going (this is the can’t travel in what’s not enclosed in a vehicle rule):
let nonvehicle be the holder of the actor;
if nonvehicle is the room gone from, continue the action;
if nonvehicle is the vehicle gone by, continue the action;
if the vehicle gone by encloses the nonvehicle, continue the action;
if the actor is the player:
if nonvehicle is a supporter:
say “[We] [would have] to get off [the nonvehicle] first.” (A);
otherwise:
say “[We] [would have] to get out of [the nonvehicle] first.” (B);
stop the action.

The can’t travel in what’s not enclosed in a vehicle rule is listed instead of the can’t travel in what’s not a vehicle rule in the check going rulebook. [/code]

OK, but!

I haven’t done anything about your second issue, riding the powerchair out of the elevator. One reason is that it’s hard to interpret player intention–when the player types “exit” do they mean exiting the powerchair or exiting the elevator? If they type “stand up” they definitely mean the powerchair, if they type “out” they probably mean the elevator, but in this case both those wind up getting redirected to exiting.

Also, the elevator doesn’t seem like it’s that vehicular. It only moves on a particular path. The power of vehicles is that they make it easy to move the way you would move anyway without getting off the vehicle. One thing that might be easier than making the elevator a vehicle, and rewriting a bunch of rules to accommodate vehicles within vehicles, would be to make an “instead of going up/down when the elevator encloses the player” rule.

BTW, the “After going up” and “After going down” rules seem too broad (unless the only way the player will be able to go up and down is in the elevator), and the messages for going up and down when not in the elevator will tell the player that they’re on wheels even if they’ve gotten out of the powerchair!

Whoa! Thank you matt! I’m going to try that out, and see if I can solve exiting to my satisfaction, and then will post whatever I come up with here. The reason I was going with elevator as vehicle is that I’m simulating an entire train system, so there are like, 60 elevators, each of which touch upon 3 or 4 rooms. That’s why I want my elevator to magically appear and go along a “track”. Otherwise I have to define particular code for 60 different elevators and what connects to them.

Definitely check the Recipe Book regarding this: inform7.com/learn/man/RB_8_2.html

You can use various tricks to make sure you don’t have to write separate codes for each elevator. This tries defining a special elevator-equipped kind of room, which will have the elevator appear and move up and down according to the up-down connections we’ve defined for the rooms. It takes a special rule for going up and down in the elevator. This is partly based on the first example in the Recipe Book section Hanon linked, where you change the elevator’s map connections.

(I only used one elevator–if the player drops something in the elevator then it will reappear even in a different station’s elevator. So I made a quick and dirty rule preventing that! It’s true, if you drop something in an elevator it’ll likely get lost.)

Also I had a crudeish rule that’s designed to keep the game from intercepting commands like “out” when the player is in the powerchair, so they only try exiting if they actually typed “stand.”

[code]“Lift” by lizzard

Include Rideable Vehicles by Graham Nelson.

An elevator-equipped room is a kind of room.

House is a room. “North of you, there’s a busy street.”
Street is an elevator-equipped room. It is north of House. “Try looking again, then you may find an elevator.”
Concourse is an elevator-equipped room. It is down from Street. “A train concourse.”
Platform is an elevator-equipped room. It is down from Concourse. “A train platform.”

Backwater Platform is an elevator-equipped room.
Backwater Station is an elevator-equipped room. It is up from Backwater Platform.

The Elevator is a room. “A spacious elevator. [elevator direction text].”

To say elevator direction text:
let the exit be the room outside from the elevator;
if the room up from the exit is not nothing:
if the room down from the exit is not nothing:
say “You can go up or down as well as out”;
otherwise:
say “You can go up as well as out”;
otherwise: [no room up from the exit]
if the room down from the exit is not nothing:
say “You can go down as well as out”;
otherwise:
say “You can only go out”.

Every turn when the location [“of the player” is optional] is an elevator-equipped room and the elevator is not the room inside from the location:
say “The elevator arrives. You can go inside now.”;
now the elevator is mapped inside the location;
now the location is mapped outside the elevator.

Instead of going up in an elevator-equipped room:
say “That’s fairly challenging since your wheels won’t make it up the stairs.”

Instead of going down in an elevator-equipped room:
say “Quite challenging, since your wheels won’t make it down the stairs.”

Instead of going up in the elevator:
let the new exit be the room up from the room outside from the elevator;
if the new exit is not nothing:
now the new exit is mapped outside the elevator;
now the elevator is mapped inside the new exit;
say “The elevator takes you up with Lizzard’s message which unfortunately I snipped out before writing this.”;
otherwise:
say “The elevator can’t go up from here.”

Instead of going down in the elevator:
let the new exit be the room down from the room outside from the elevator;
if the new exit is not nothing:
now the new exit is mapped outside the elevator;
now the elevator is mapped inside the new exit;
say “The elevator takes you down etc.”;
otherwise:
say “The elevator can’t go down from here.”

Instead of waiting in Platform:
say “A mysterious train picks you up and deposits you in Backwater Platform. Go up in the elevator, then play Cragne Manor.”;
if the player is on the powerchair:
now the powerchair is in Backwater Platform;
otherwise:
now the player is in Backwater Platform.

A snazzy powerchair is a rideable vehicle. A snazzy powerchair is in House.
The player is on a snazzy powerchair.

Before exiting when the player is on the powerchair and the player’s command does not include “stand”:
try going outside instead.

Instead of dropping something in the elevator:
say “Don’t do that! You’ll never see it again.”[/code]

Thanks Matt W! That is kind of close to what I got to eventually. After trying many different things, I ended up making the elevator a room – one room that appears magically in any location where an elevator should be, defined by region, and which behaves in particular ways depending on whether there are rooms mapped above and below it. I have not thought through the ideas about dropping things in the elevator. It may actually fit with the plot for the player to realize the elevator is magically the same in each train station. Not sure yet.

At some point, I realized the wheelchair would be easier to deal with as a wearable object, with different rules for how to describe wearing it or removing it to the player and for listing it in inventory as something like (being sat on) or (being ridden) rather than (being worn). Even if I solved the wheelchair and elevator problem (which I did a couple of different ways) I was then left with the wheelchair and the train, another vehicle! And the Transit System extension is so handy that I didn’t want to abandon the train as vehicle.

Now things are hacked together a bit crudely with a modified version of Touchy Feely and some mobility, sightedness, and deafness rules, you can see my progress at github.com/lizzard/transitory as I go if you like!