Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

More handy code (elevator)

1 view
Skip to first unread message

Sam Hulick

unread,
Aug 18, 1995, 3:00:00 AM8/18/95
to

Just in case anyone is interested, here's a fully functional elevator.
It's one lacking point is that when you press a button to go to another
floor, it goes there immediately and the doors open (ok, so I got a
little lazy), whereas if it's on, say, floor four when you summon it, it
takes X turns to come down to you. Heres the code.
Check out the !comments! throughout the code.

elevator.inf:
=============
! Elevator code--way cool

Object elev_summon "elevator button"
with name "button",
time_left 0,
time_out [;
elev_doors.number = location.number;
give elev_doors open;
give self ~general;
StartTimer(elev_doors, 1);
"There is a ~ding~ and the elevator doors open before you.";
],
found_in hotel_elev elev_fl1 elev_fl2 elev_fl3 elev_fl4,
! These are just rooms in my game. hotel_elev is the lobby level, and
! the other floors are 1-4. elev_doors.number keeps track of where the
! elevator is. -1 meaning the lobby level, and 1-4 meaning those floors.

description [;
print "It's just a white button with an arrow on it, pointing upward";
if (self has general) ". The button is lit.";
else ".";
],
before [;
Push: if (elev_doors has open && elev_doors.number == location.number)
"The doors are already open!";
if (self hasnt general)
{
if (elev_doors.number ~= location.number)
{
give self general;
StartTimer(elev_summon, elev_doors.number);
"The button lights up.";
}
give elev_doors open;
StartTimer(elev_doors, 1);
"The elevator doors open immediately.";
}
"Nothing happens. Be patient, eh?";
],
has scenery concealed;

Object elev_doors "elevator door"
with name "door" "door" "elevator",
number 4, !! I start my elevator on the 4th floor, so when the
! player presses the button, it takes time to arrive.
time_left 0,
time_out [;
give self ~open;
"The elevator door slides shut.";
],
article "an",
description [;
print "The door is gold-colored and very shiny. ";
if (self has open) "It is currently closed.";
"The door is shut.";
],
found_in hotel_elev elev_fl1 elev_fl2 elev_fl3 elev_fl4 in_elev,
door_to [;
if (myloc() == in_elev) ! see myloc() below
{
if (self.number == -1) return hotel_elev;
if (self.number == 1) return elev_fl1;
if (self.number == 2) return elev_fl2;
if (self.number == 3) return elev_fl3;
if (self.number == 4) return elev_fl4;
}
return in_elev;
],
door_dir [;
if (myloc() == in_elev) return out_to;
return in_to;
],
before [;
Go, Enter: <<Go e_obj>>;
],
has door static;

Object in_elev "Elevator"
with description "You're inside the hotel elevator. It is rather \
nicely carpeted, just like the rest of the building. \
There's a panel on the wall with an assortment of \
buttons. You can exit to the west.",
out_to elev_doors,
w_to elev_doors
has light lit;

Object elev_panel "control panel" in_elev
with name "panel" "control",
description "You're looking at the control panel to the elevator. \
On it are buttons labelled L (lobby), and one through four."
has static transparent;

Class elev_button
with description "Just a button.",
before [;
Push: if (elev_doors.number ~= self.number)
{
if (elev_doors has open)
{
print "The elevator door closes as you press the button.^";
give elev_doors ~open;
StopTimer(elev_doors);
}
elev_doors.number = self.number;
give elev_doors open;
StartTimer(elev_doors, 1);
"You feel the elevator move momentarily, then stop. \
The door opens.";
}
if (elev_doors hasnt open)
{
give elev_doors open;
StartTimer(elev_doors, 1);
"The door opens as you press the button.";
}
];

Nearby lbutton "lobby button"
class elev_button
with name "button" "L" "lobby",
number -1;

Nearby onebutt "first button"
class elev_button
with name "button" "one" "first",
number 1;

Nearby twobutt "second button"
class elev_button
with name "button" "two" "second",
number 2;

Nearby threebutt "third button"
class elev_button
with name "button" "three" "third",
number 3;

Nearby fourbutt "fourth button"
class elev_button
with name "button" "four" "fourth",
number 4;

---cut here---

So, the floor numbers are in the 'number' property on the buttons. When
you press a button, the elevator moves to the button.number.

myloc() is just a routine I made because I got sick of thedark
bullshit. It's quite simple:

[ myloc;
if (location == thedark) return real_location;
return location;
];

Enjoy

--
--- Sam Hulick ------------- shu...@indiana.edu ---------------------
Systems Consultant | Homepage:
Indiana College Placement | http://copper.ucs.indiana.edu/~shulick/
and Assessment Center | PGP public key available on request

0 new messages