Traversable (e.g. with Approaching by Emily Short) Elevators

I have written some generic template code to make Elevators.
Not so impressive in and of itself, (in fact arguably a bad idea, since making big mostly empty buildings makes for a boring landscape) but mostly I want to be able to have the NPCs and players traverse the elevators.

[spoiler][code]
“Elevators” by “Anonymous”

Include Room Description Control by Emily Short.

A multi-story building is a kind of region.
An elevator is a kind of room.

A floor is a kind of room. A floor has some number called floor number.
Understand the floor number property as describing a floor.
After looking when the location is an elevator:
say “There is an array of buttons labeled from 1 to [floor number of highest floor in a random multi-story building containing the location].”;
say “Underneath the numbered buttons are several other unimportant buttons.”;

Floor numbering relates one number to various floors.
The verb to have-floor-number (he has-floor-number, they have-floor-number, it has-floor-number) means the reversed floor numbering relation.
A lobby is a kind of floor.

An elevator button is a kind of thing.

An elevator call button is a kind of elevator button.
“A simple unmarked button sits next to the elevator doors.”
The description is “It probably calls the elevator.”

el-floor-calling relates a floor (called the floor-to-call) to an elevator call button.
The verb to el-floor-call means the reversed el-floor-calling relation.
An elevator call button el-floor-calls every floor.

An elevator go button is a kind of elevator button.

Before looking when the location is an elevator:
[with room description control, prevent describing elevator go buttons]
[FIXME - way to do this w/o Room Description Control?]
now every elevator go button within the location is mentioned.

instead of examining an elevator go button (called the button):
say “A button labeled [floor number of button][if floor-to-go of the button is a lobby] with a little star next to it[end if].”.

el-floor-going relates a floor (called the floor-to-go) to an elevator go button.
The verb to el-floor-go means the reversed el-floor-going relation.
An elevator go button el-floor-goes every floor.
An elevator go button has a number called floor number.
Understand “[something related by el-floor-going] button”, “button for/- [something related by el-floor-going]” as an elevator go button.
Understand the floor number property as describing an elevator go button.
To decide what number is the current level of (el - an elevator):
decide on the floor number of the room outside from el.
Rule for printing the name of an elevator go button (called it):
say “[floor number of it] button”.

A null go button is a kind of privately-named elevator go button.
elevator button ether is a room.
In the elevator button ether there are 100 null go buttons.

when play begins:
let null buttons be the list of all null go button;
repeat with b running through every multi-story building:
let el be a random elevator within b;
if there is an elevator (called el) within b:
let lb be a random lobby within b;
now el is mapped inside lb;
now lb is mapped outside el;
repeat with f running through every floor within b:
let callbtn be an elevator call button that f relates to by the el-floor-calling relation;
let gobtn be an elevator go button that f relates to by the el-floor-going relation;
now f has-floor-number floor number of f;
now the floor number of gobtn is floor number of f;
move callbtn to f;
move gobtn to el;
let max floor number be the floor number of the highest floor contained in b;
repeat with n running from 1 to max floor number:
if there is not a floor that has-floor-number n contained in b:
do nothing;
otherwise:
let nobtn be entry 1 of null buttons;
remove entry 1 from null buttons;
now the floor number of nobtn is n;
move nobtn to el;
otherwise:
say “Oops! the author forgot to put an elevator inside [b].”.

Definition: A floor is high if its floor number is 10 or more.
Definition: A floor is low if its floor number is 5 or less.

Instead of switching on, touching or attacking an elevator button, try pushing the noun.

Carry out pushing an elevator call button:
let msr be a random multi-story building containing the location;
let el be a random elevator within msr;
now el is mapped inside the location;
now the location is mapped outside el;

Report pushing an elevator call button:
say “The button lights up and a few moments later [we] hear a ‘ding!’. The elevator doors open with a [italic type]swoosh[roman type].”.

[Go buttons]

Check pushing a null go button:
say “[We] don’t want to go to floor [floor number of the noun].” instead.

Check pushing an elevator go button:
let current floor be the room outside from the location;
if current floor is the floor-to-go of the noun, say “The doors open again, but it’s the same floor [we] just stepped in from.” instead.

Carry out pushing an elevator go button:
let f be floor-to-go of the noun;
now the location is mapped inside f;
now f is mapped outside the location;

report pushing an elevator go button:
say “[We] feel the ground move and hear a [italic type]whoosh![roman type]. After a moment, it stops and the doors open.”;
stop the action.

After looking when the location is an elevator and the location was not an elevator:
say “The doors [italic type]whoosh[roman type] closed behind [us].”

Section Example

[actual rooms on floors elided for conciseness.]
Ondine is a multi-story building.
Ondine Elevator is an elevator in Ondine.
“A rickety elevator. It doesn’t feel safe, but the repair guy has assured [us] it is.”
Ondine lobby is a lobby in Ondine. The floor number is 1.
“A pleasant lobby welcomes you to The Ondine Dormitory.”
Ondine Floor 2 is a floor in Ondine. The floor number is 2.
“There are classrooms on this floor.”
Ondine Floor 6 is a floor in Ondine. The floor number is 6.
“[Our] dorm should be just around the corner.”.

Player’s Dorm is a room within Ondine. It is south of Ondine Floor 6. The printed name is “[Our] Dorm”.
“A total pigsty.”

Broadway Building is a multi-story building.
Broadway Elevator is an elevator within the Broadway Building.
“A modern elevator. It feels kinda cramped.”
The Broadway Lobby is a lobby within The Broadway Building. The floor number is 1.
“A spartan lobby designated for residents, the ‘real’ lobby for students is one floor up.”
The Broadway Floor 2 is a floor within The Broadway Building. The floor number is 2.
“Classrooms and computer lab on this floor.”
The Broadway Floor 5 is a floor within The Broadway Building. The floor number is 5.
“Drew’s dorm is on this floor.”

Drew’s Dorm is a room within The Broadway Building. It is south of Broadway Floor 5.
“This room is unusually clean for a college kid.”

Fourth Avenue is a room. It is west of The Broadway Lobby and east of Ondine Lobby.
“A bustling street. College kids bustle about trying to get to their next class.”

when play begins: move the player to Fourth Avenue.

test me with “e / in / push 4 / push 100 / push 5 / out”.
[/code][/spoiler]

Let’s say I want to be able to have an NPC Drew that can automatically follow a schedule (go to the cafeteria, go to class, go back to his dorm at the end of the day). So I want to be able to have some sort of “the best route from x to y” that can traverse elevators.
My first approach to this was to just define a bunch of directions called floor 1-whatever that were opposites of inside. This seems janky though. (maybe less janky than alternatives?).

The only options I can see are super-convoluted, and make assumptions like buildings open out onto a street that acts as a nexus. and that rooms that branch out from floors are within the multi-story building region.

I’m re-reading the “Dubai” example. I think I have some ideas on how to make it better, but traversing is still eluding me.