FAQ Search Memberlist Usergroups
Jolt Country Forum Index
Register Profile Log in to check your private messages Log in
Log in Log in

Elevator Implementation

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors
View previous topic :: View next topic  
Author Message
Tdarcos



Joined: 16 May 2008
Posts: 4441
Location: University Park, Maryland

PostPosted: Tue Sep 18, 2012 3:00 am    Post subject: Elevator Implementation Reply with quote

A multi-story department store has to have an elevator. (For the purists in the peanut gallery who are screaming about my revolving door and the extra work to travel, there are also escalators elsewhere in the building, which simply go up and down.)

So here's how I implement an elevator.

Code:

!! 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 use an object as the elevator cage in order to have one room as the elevator, which appears to move as the elevator does. If the user uses the escalator to go to a floor where the elevator isn't there, then they PUSH CALL to call for the elevator. Doing that when it is there doesn't do anything.

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.
_________________
The lessons of history teach us - if they teach us anything - that no one learns the lessons of history.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Thu Jan 31, 2013 12:05 pm    Post subject: Reply with quote

I forgot I did my own elevator implementation over at the IF Wiki as a Hugo coding example. My elevator behavior is modeled after the elevator in Infocom's The Lurking Horror:
http://ifwiki.org/index.php/Elevator_and_stairs_%28Hugo_example%29
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Theme by Kage Musha - RPG Garden

Copyrights and trademarks are all of the belonging company. No copyright Infringement intended