So here's how I implement an elevator.
Code: Select all
!! Verbs
verb "push","press"
* DoVague
* pushable DoPush
* "b"/"1"/"2"/"3" DoElevator
!! Verb processing code
Routine DoPush
{
!... push something else ...
! Push elevator call button
if (object = callb) {
if (location=parent(callb))
{
print "The elevator is already here. Go IN to enter elevator."
} else {
move elevator_object to location
elevator.name = nameelevator(location)
print "Ding! The elevator arrives."
moveplayer (location)
}
}
! ... push other things ...
}
routine DoElevator
{
local destination
if (location ~= elevator)
{
print "I don't see that here"
return
}
select word[2]
case "b": destination = Store_B_elevator
case "1": destination = Store_1_elevator
case "2": destination = Store_2_elevator
case "3": destination = Store_3_elevator
if (destination = parent(elevator_object))
{
print "You're already there."
return
}
print "The doors close, the elevator starts,
the elevator moves, it stops, the bell rings, the doors open."
move elevator_object to destination
elevator.name = NameElevator(destination)
move callb to destination
moveplayer(location) ! So the elevator title is redrawn
}
Routine NameElevator (Where)
{
select where
case Store_B_elevator
return "Inside the elevator, at the basement"
case Store_1_elevator
return "Inside the elevator, on the first floor"
case Store_2_elevator
return "Inside the elevator, on the second floor"
case Store_3_elevator
return "Inside the elevator, on the third floor"
return "** Unknown elevator location **"
}
!! Attributes / properties
attribute Pushable ! Can be pushed or pressed
!! Rooms/Objects
room Store_1_elevator "First floor elevator waiting area"
{
E_to Store ! unimportant location
NE_to Store_1_06
IN_to
{
if (location=parent(elevator_object))
{
moveplayer(elevator)
} else {
print "The elevator isn't here."
}
}
long_desc
{
if location = parent(elevator_object)
{
print "Go IN to enter elevator."
}
else
{
move callB to location
print "Press CALL button to call for the elevator. Go IN when it arrives."
}
print "Go EAST to return to the store entrance,
or NORTHEAST to Department 6."
}
}
object CallB "elevator call button"
{
in store_1_elevator
article "the"
adjectives "call","button"
is pushable,static,hidden
}
object elevator_object
{
article "the"
in store_1_elevator
is static
short_desc
{
"The elevator is here."
}
}
room elevator "Inside the elevator, on the first floor"
{
OUT_to
{
moveplayer(parent(elevator_object))
}
long_desc
{
if elevator is not beenhere ! Only show picture first time
picture "wnselevator.jpg"
elevator is beenhere
print "Press button for desired floor: PRESS B, PRESS 1, PRESS 2 or PRESS 3.
When the elevator arrives, go OUT or EXIT to leave.\n
\"NOTICE: Smoking is not permitted in elevators.\" \n- Winnemac B&E Code Sec. 70005."
}
}
room Store_1_06 "First floor Department 6."
{
SE_to Store ! Unimportant location for this demo
E_to Store_1_escalator ! Unimportant location for this demo
SW_to
{
move CallB to Store_1_elevator
MovePlayer(Store_1_elevator)
}
long_desc
"Go SOUTHEAST to return to the store entrance,
SOUTHWEST to the elevator, or
EAST to the escalators."
}
! Basement
room Store_B_elevator "Basement elevator waiting area"
{
NE_to Store_B_06 ! Unimportant location for this demo
IN_to
{
if (location=parent(elevator_object))
{
moveplayer(elevator)
} else {
print "The elevator isn't here."
}
}
long_desc
{
if location ~= parent(elevator_object)
print "Press CALL button to call for the elevator.\n
Go ";
else
print "Go IN to enter elevator, or ";
print "NORTHEAST to Department 6."
}
}
room Store_B_06 "Basement Department 6."
{
E_to Store_B_escalator ! Unimportant location for this demo
SW_to
{
move CallB to Store_B_elevator
MovePlayer(Store_B_elevator)
}
long_desc
"Go SOUTHWEST to the elevator, or EAST to the escalator."
}
! Second Floor
room Store_2_elevator "Second Floor elevator waiting area"
{
NE_to Store_2_06 ! Unimportant location for this demo
IN_to
{
if (location=parent(elevator_object))
{
moveplayer(elevator)
} else {
print "The elevator isn't here."
}
}
long_desc
{
if location ~= parent(elevator_object)
print "Press CALL button to call for the elevator.\n
Go ";
else
print "Go IN to enter elevator, or ";
print "NORTHEAST to Department 6."
}
}
room Store_2_06 "Second Floor Department 6."
{
E_to Store_2_escalator ! Unimportant location for this demo
SW_to
{
move CallB to Store_2_elevator
MovePlayer(Store_2_elevator)
}
long_desc
"Go SOUTHWEST to the elevator, or EAST to the escalators."
}
!! additional floors as needed
I have the room before the elevator - as well as the elevator itself when moved - move the call button to the elevator waiting area of the floor where the user is at. This way there only needs to be one call button.