Elevator and stairs (JACL example): Difference between revisions

From IFWiki

m (missing word in text.)
m (Fixed bug.)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
(This sample can be [http://jacl.game-host.org:8080/fastcgi-bin/elevator.jacl played online].)
The guy who did the Inform example wasn't wrong...
The guy who did the Inform example wasn't wrong...


Line 6: Line 4:
#!../bin/jacl
#!../bin/jacl


attribute OUTSIDE_LIFT
variable GAME_VERSION 2
string GAME_TITLE "Smell Restrictions"
 
attribute OUTSIDE_LIFT


variable FLOOR_MAPPING ground_floor first_floor second_floor
variable FLOOR_MAPPING ground_floor first_floor second_floor
Line 12: Line 13:
{+intro
{+intro
clear
clear
write "^^<h2>Elevator and stairs example</h2>^^"
write "^^Elevator and stairs example^^"
look
execute "+look_around"
}
}


Line 23: Line 24:
  short the "ground floor"
  short the "ground floor"
  has OUTSIDE_LIFT
  has OUTSIDE_LIFT
  up first_floor
  up first_floor


{look
{look
write "<p>You are on the ground floor. The "
write "You are on the ground floor. The "
if here(north) != nowhere
if here(north) != nowhere
   write "open "
   write "open "
Line 32: Line 33:
   write "closed "
   write "closed "
endif
endif
write "door door to an elevator is to the north and a set of stairs lead up. "
print:
write "Beside the door is a call button.^"
  door door to an elevator is to the north and a set of stairs lead up.
  Beside the door is a call button.^
.
}
}


Line 46: Line 49:
{examine
{examine
if here = ground_floor
if here = ground_floor
   write "<p>The go stairs up.^"
   write "The stairs go up.^"
endif
endif
if here = first_floor
if here = first_floor
   write "<p>The go stairs up and down.^"
   write "The go stairs up and down.^"
endif
endif
if here = second_floor
if here = second_floor
   write "<p>The go stairs down.^"
   write "The go stairs down.^"
endif
endif
}
}
Line 58: Line 61:
{take
{take
if here = first_floor
if here = first_floor
   write "<p>Do you want to take the stairs up, or take the stairs down?^"
   write "Do you want to take the stairs up, or take the stairs down?^"
endif
endif
if here = ground_floor
if here = ground_floor
Line 79: Line 82:


{+take_up
{+take_up
write "<p>You can't take " noun1{the} " up.^"
write "You can't take " noun1{the} " up.^"
}
}


Line 85: Line 88:


{+take_down
{+take_down
write "<p>You can't take " noun1{the} " down.^"
write "You can't take " noun1{the} " down.^"
}
}


object call_button_g: call button
object callbuttong: call button
  short a "call button"
  short a "call button"
  floor 0
  floor 0


{examine
{examine : *examine_callbutton1 : *examine_callbutton2
execute +examine_call_button<this
write "Pushing this button summons the elevator to this floor. It's currently "
if self has ON
  write "lit.^"
else
  write "dark.^"
endif
}
}


{press : move
{press : *press_callbutton1 : *press_callbutton2
execute +press_call_button<this
if lift_obj(moving_to) != arrived
  write "The button lights as you press it, only to go off again when you release it.^"
  return
endif
if lift_obj(floor) = self(floor)
  if here(out) = nowhere
      write "The lift doors slide open.^"
      execute "+lift_open"
      return
  endif
  write "The button lights as you press it, only to go off again when you "
  write "release it.^"
  return
endall
set lift_obj(moving_to) = self(floor)
ensure self has ON
write "The button lights up as you press it.^"
}
}


Line 104: Line 128:


{look
{look
write "<p>You are inside the elevator. The door to the south is "
write "You are inside the elevator. The door to the south is "
if here(south) != nowhere
if here(south) != nowhere
   write "open, "
   write "open, "
Line 116: Line 140:
if COMPASS = south : COMPASS = out
if COMPASS = south : COMPASS = out
   if destination = nowhere
   if destination = nowhere
       write "<p>The lift doors are currently closed.^"
       write "The lift doors are currently closed.^"
       break
       return
endall
endall
if destination = false
if destination = false
   write "<p>The only way out of the lift is to the west.^"
   write "The only way out of the lift is to the west.^"
   break
   return
endif
endif
break false
return false
}
}
   
   
object c_button: east eastern close door button control 1
object cbutton: east eastern close door button control 1
  short a "close doors button"
  short a "close doors button"


{press : move
{press : move
if lift_obj(turns_till_doors_close) = 0
if lift_obj(turns_till_doors_close) = 0
   write "<p>The doors are already closed.^"
   write "The doors are already closed.^"
   set TIME = false
   set TIME = false
   break
   return
endif
endif
write "<p>The lift doors slide closed.^"
write "The lift doors slide closed.^"
execute "+lift_close"
execute "+lift_close"
}
}


object o_button: east eastern open door button control 1
object obutton: east eastern open door button control 1
  short an "open doors button"
  short an "open doors button"


{press : move
{press : move
if lift_obj(turns_till_doors_close) > 0
if lift_obj(turns_till_doors_close) > 0
   write "<p>The doors are already open.^"
   write "The doors are already open.^"
   set TIME = false
   set TIME = false
   break
   return
endif
endif
if lift_obj(moving_to) != arrived
if lift_obj(moving_to) != arrived
   write "<p>The lift doors refuse to open while the lift is in motion.^"
   write "The lift doors refuse to open while the lift is in motion.^"
   break
   return
endif
endif
write "<p>The lift doors slide open.^"
write "The lift doors slide open.^"
execute "+lift_open"
execute "+lift_open"
}
}


{+floor_button_press
object gbutton: ground floor button g
if lift_obj(moving_to) != arrived
  write "<p>The button lights as you press it, only to go off again when you "
  write "release it.^"
  break
endif
if lift_obj(floor) = arg[0](floor)
  if here(out) = nowhere
      write "<p>The lift doors slide open.^"
      execute "+lift_open"
      break
  endif
  write "<p>The button lights as you press it, only to go off again when you "
  write "release it.^"
  break
endall
set lift_obj(moving_to) = arg[0](floor)
ensure arg[0] has ON
write "<p>The button lights up as you press it.^"
}
 
object g_button: ground floor button g
  short a "ground floor button"
  short a "ground floor button"
  floor 0
  floor 0


{press : move
{press : move
execute +floor_button_press<self
execute +floorbuttonpress<self
}
}


object 1_button: first floor button 1
object 1button: first floor button 1
  short a "first floor button"
  short a "first floor button"
  floor 1
  floor 1


{press : move
{press : move
execute +floor_button_press<self
execute +floorbuttonpress<self
}
}


object 2_button: second floor button 2
object 2button: second floor button 2
  short a "second floor button"
  short a "second floor button"
  floor 2
  floor 2


{press : move
{press : move
execute +floor_button_press<self
execute +floorbuttonpress<self
}
}


Line 205: Line 208:


{examine
{examine
write "<p>The panel consists of five buttons labelled ground, one, two, "
write "The panel consists of five buttons labelled ground, one, two, "
write "open and close. "
write "open and close. "
if g_button has ON
if gbutton has ON
   write "The button for the ground floor is currently lit."
   write "The button for the ground floor is currently lit."
endif
endif
if 1_button has ON
if 1button has ON
   write "The button for the first floor is currently lit."
   write "The button for the first floor is currently lit."
endif
endif
if 2_button has ON
if 2button has ON
   write "The button for the second floor is currently lit."
   write "The button for the second floor is currently lit."
endif
endif
Line 226: Line 229:


{examine
{examine
write "<p>Above the panel is an LED display with a large red '"
write "Above the panel is an LED display with a large red '"
write led_display[lift_obj(floor)] "'.^"
write led_display[lift_obj(floor)] "'.^"
}
}
Line 233: Line 236:
constant floor 5
constant floor 5
constant moving_to 6
constant moving_to 6
constant arrived 42; POSSIBLE VALUE OF moving_to
constant arrived         42; POSSIBLE VALUE OF moving_to
constant turns_till_doors_close 7
constant turns_till_doors_close                 7
constant delta 8
constant delta 8


Line 243: Line 246:
{examine
{examine
if lift_obj(turns_till_doors_close) > 0;
if lift_obj(turns_till_doors_close) > 0;
   write "<p>The lift doors are open.^"
   write "The lift doors are open.^"
else
else
   write "<p>The lift doors are closed.^"
   write "The lift doors are closed.^"
endif
endif
}
}
Line 251: Line 254:
{enter
{enter
if here = lift
if here = lift
   write "<p>You are already in the lift.^"
   write "You are already in the lift.^"
   set TIME = false
   set TIME = false
   break
   return
endif
endif
proxy "east"
proxy "east"
Line 260: Line 263:
{open
{open
if lift_obj(turns_till_doors_close) > 0;
if lift_obj(turns_till_doors_close) > 0;
   write "<p>The lift doors are already open.^"
   write "The lift doors are already open.^"
   break
   return
endif
endif
if here = lift
if here = lift
   write "<p>(by pressing the open doors button)^"
   write "(by pressing the open doors button)^"
   proxy "press open doors button"
   proxy "press open doors button"
   break
   return
endif
endif
write "<p>(by pressing the call button)^"
write "(by pressing the call button)^"
proxy "press call button"
proxy "press call button"
}
}
Line 274: Line 277:
{close
{close
if lift_obj(turns_till_doors_close) = 0;
if lift_obj(turns_till_doors_close) = 0;
   write "<p>The lift doors are already closed.^"
   write "The lift doors are already closed.^"
   break
   break
endif
endif
if here = lift
if here = lift
   write "<p>(by pressing the close doors button)^"
   write "(by pressing the close doors button)^"
   proxy "press close doors button"
   proxy "press close doors button"
   break
   return
endif
endif
write "<p>There is no way to close the lift doors from the outside.^"
write "There is no way to close the lift doors from the outside.^"
}
}


Line 292: Line 295:


{look
{look
write "<p>You are on the first floor. The "
write "<You are on the first floor. The "
if here(north) != nowhere
if here(north) != nowhere
   write "open "
   write "open "
Line 298: Line 301:
   write "closed "
   write "closed "
endif
endif
write "door door to an elevator is to the north and a set of stairs lead up "
print:
write "and down from here. "
  door door to an elevator is to the north and a set of stairs lead up
write "Beside the door is a call button.^"
  and down from here. Beside the door is a call button.^
.
}
}


{movement
{movement
break +door_warning
if +door_warning = true
break false
  return true
endif
return false
}
}


object call_button_1: call button
object callbutton1: call button
  short a "call button"
  short a "call button"
  floor 1
  floor 1
{examine
execute +examine_call_button<this
}
{press : move
execute +press_call_button<this
}


location second_floor : second floor
location second_floor : second floor
Line 326: Line 324:


{look
{look
write "<p>You are on the second floor. The "
write "You are on the second floor. The "
if here(north) != nowhere
if here(north) != nowhere
   write "open "
   write "open "
Line 332: Line 330:
   write "closed "
   write "closed "
endif
endif
write "door door to an elevator is to the north and a set of stairs lead "
print:
write "down. Beside the door is a call button.^"
  door door to an elevator is to the north and a set of stairs lead
  down. Beside the door is a call button.^
.
}
}


Line 341: Line 341:
}
}


object call_button_2: call button
object callbutton2: call button
  short a "call button"
  short a "call button"
  floor 2
  floor 2
{examine
execute +examine_call_button<this
}
{press : move
execute +press_call_button<this
}


{+lift_close
{+lift_close
Line 386: Line 378:
   if lift_obj(turns_till_doors_close) = 0
   if lift_obj(turns_till_doors_close) = 0
       if here = lift : here = FLOOR_MAPPING[lift_obj(floor)]
       if here = lift : here = FLOOR_MAPPING[lift_obj(floor)]
         write "<p>^The lift doors slide closed.^"
         write "^The lift doors slide closed.^"
       endif
       endif
       execute "+lift_close"
       execute "+lift_close"
   endif
   endif
   break # THE LIFT CAN'T DO ANYTHING ELSE UNTIL THE DOORS HAVE CLOSED
   return # THE LIFT CAN'T DO ANYTHING ELSE UNTIL THE DOORS HAVE CLOSED
endif
endif
if lift_obj(moving_to) != arrived
if lift_obj(moving_to) != arrived
Line 403: Line 395:
       endif
       endif
       if here = lift
       if here = lift
         write "<p>^The lift vibrates as it slowly "
         write "^The lift vibrates as it slowly "
         if lift_obj(delta) < 0
         if lift_obj(delta) < 0
             write "descends.^"
             write "descends.^"
Line 410: Line 402:
         endif
         endif
       endif
       endif
       break
       return
   endif
   endif
   set lift_obj(moving_to) = arrived
   set lift_obj(moving_to) = arrived
   if here = FLOOR_MAPPING[lift_obj(floor)]
   if here = FLOOR_MAPPING[lift_obj(floor)]
       write "<p>^A crisp-sounding bell rings briefly and the doors "
       write "^A crisp-sounding bell rings briefly and the doors "
       write "to the lift slide open.^"
       write "to the lift slide open.^"
   endif
   endif
   if here = lift
   if here = lift
       write "<p>^Having arrived at the selected floor, the lift "
       write "^Having arrived at the selected floor, the lift "
       write "gently comes to a halt and the doors open.^"  
       write "gently comes to a halt and the doors open.^"  
   endif
   endif
   execute "+lift_open"
   execute "+lift_open"
   execute "+disable_call_buttons"
   execute "+disable_callbuttons"
endif
endif
}
}


{+press_call_button
{+press_callbutton
if arg[0] has ON
if arg[0] has ON
   write "<p>The call button has already been pressed.^"
   write "The call button has already been pressed.^"
   set TIME = false
   set TIME = false
   break
   return
endif
endif
if lift_obj(floor) = arg[0](floor)
if lift_obj(floor) = arg[0](floor)
   if lift_obj(turns_till_doors_close) > 0
   if lift_obj(turns_till_doors_close) > 0
       write "<p>There is already a lift here.^"
       write "There is already a lift here.^"
       set TIME = false
       set TIME = false
       break
       return
   endif
   endif
   write "<p>A crisp-sounding bell rings briefly and the doors "
   write "A crisp-sounding bell rings briefly and the doors "
   write "to the lift slide open.^"
   write "to the lift slide open.^"
   execute "+lift_open"
   execute "+lift_open"
   ensure arg[0] hasnt ON
   ensure arg[0] hasnt ON
   break
   return
endif   
endif   
write "<p>As you press the call button it lights up.^"
write "<p>As you press the call button it lights up.^"
Line 449: Line 441:
}
}


{+examine_call_button
{+disable_callbuttons
write "<p>Pushing this button summons the elevator to this floor. It's "
ensure gbutton hasnt ON
write "currently "
ensure 1button hasnt ON
if arg[0] has ON
ensure 2button hasnt ON
  write "lit.^"
ensure callbuttong hasnt ON
  break
ensure callbutton1 hasnt ON
endif
ensure callbutton2 hasnt ON
write "dark.^"
}
 
{+disable_call_buttons
ensure g_button hasnt ON
ensure 1_button hasnt ON
ensure 2_button hasnt ON
ensure call_button_g hasnt ON
ensure call_button_1 hasnt ON
ensure call_button_2 hasnt ON
}
}


Line 471: Line 453:
if COMPASS = north : COMPASS = in
if COMPASS = north : COMPASS = in
   if destination = false
   if destination = false
       write "<p>The lift doors are closed.^"
       write "The lift doors are closed.^"
       break
       return
   endif
   endif
endif
endif
break false
return false
}
}


Line 485: Line 467:
  player
  player


location prologue : prologue
#include "verbs.library"
short name "Game Over"
 
{look
write "<p>The game is over. Type <b>restart</b> or <b>restore</b>. "
write "A <b>restore</b> command can optionally be followed by a filename.</p>^"
}


{+header
write "Content-type: text/html"
write "Expire: -1^^"
write "<HTML><HEAD>
write "<TITLE></TITLE>"
execute "+styles"
write "<script language=~JavaScript~>"
write "function putFocus(formInst, elementInst) {"
write "if (document.forms.length > 0) {"
write "document.forms[formInst].elements[elementInst].focus();}}"
write "</script>"
write "</HEAD><BODY bgcolor=~gray~ onLoad=~putFocus(0,0);~>"
write "<FORM NAME=~GameForm~ METHOD=get>"
}
{+footer
write "<hr><center>"
prompt
execute "+exits"
execute "+score"
write "</center>"
write "</FORM>"
write "</BODY></HTML>"
}
{+styles
write "<style>"
write "  <!--"
write "  P { font-family: Helvetica, Arial, Sanserif; "
write " color: white; font-size: 14pt}"
write "  A { font-family: Helvetica, Arial, Sanserif; "
write " color: yellow; font-size: 14pt}"
write "  H1 { font-family: Helvetica, Arial, Sanserif; "
write " color: white; font-size: 24pt}"
write "  H2 { font-family: Helvetica, Arial, Sanserif; "
write " color: white; font-size: 18pt}"
write "  -->"
write "</style>"
}
#include "verbs.library"
</pre>
</pre>
[[Category:Elevator and stairs (Example)]]
[[Category:Elevator and stairs (Example)]]

Latest revision as of 02:07, 11 February 2010

The guy who did the Inform example wasn't wrong...

#!../bin/jacl

variable	GAME_VERSION	2
string		GAME_TITLE	"Smell Restrictions"

attribute	OUTSIDE_LIFT

variable FLOOR_MAPPING ground_floor first_floor second_floor

{+intro
clear
write "^^Elevator and stairs example^^"
execute "+look_around"
}

{+eachturn
execute "+lift_action"
}

location ground_floor : ground floor
 short		the "ground floor"
 has		OUTSIDE_LIFT
 up			first_floor

{look
write "You are on the ground floor. The "
if here(north) != nowhere
   write "open "
else
   write "closed "
endif
print:
   door door to an elevator is to the north and a set of stairs lead up.
   Beside the door is a call button.^
.
}

{movement
break +door_warning
break false
}

object stairs : stairs
 mass		scenery

{examine
if here = ground_floor
   write "The stairs go up.^"
endif
if here = first_floor
   write "The go stairs up and down.^"
endif
if here = second_floor
   write "The go stairs down.^"
endif
}

{take
if here = first_floor
   write "Do you want to take the stairs up, or take the stairs down?^"
endif
if here = ground_floor
   proxy "up"
endif
if here = second_floor
   proxy "down"
endif
}

{take_up
proxy "up"
}

{take_down
proxy "down"
}

grammar take *here up >take_up

{+take_up
write "You can't take " noun1{the} " up.^"
}

grammar take *here down >take_down

{+take_down
write "You can't take " noun1{the} " down.^"
}

object callbuttong: call button
 short		a "call button"
 floor		0

{examine : *examine_callbutton1 : *examine_callbutton2
write "Pushing this button summons the elevator to this floor. It's currently "
if self has ON
   write "lit.^"
else
   write "dark.^"
endif
}

{press : *press_callbutton1 : *press_callbutton2
if lift_obj(moving_to) != arrived
   write "The button lights as you press it, only to go off again when you release it.^"
   return
endif
if lift_obj(floor) = self(floor)
   if here(out) = nowhere
      write "The lift doors slide open.^"
      execute "+lift_open"
      return
   endif
   write "The button lights as you press it, only to go off again when you "
   write "release it.^"
   return
endall
set lift_obj(moving_to) = self(floor)
ensure self has ON
write "The button lights up as you press it.^"
}

location lift : lift
 short		the "elevator"

{look
write "You are inside the elevator. The door to the south is "
if here(south) != nowhere
   write "open, "
else
   write "closed, "
endif
write "and there is the usual panel of buttons beside it.^"
}

{movement
if COMPASS = south : COMPASS = out
   if destination = nowhere
      write "The lift doors are currently closed.^"
      return
endall
if destination = false
   write "The only way out of the lift is to the west.^"
   return
endif
return false
}
 
object cbutton: east eastern close door button control 1
 short		a "close doors button"

{press : move
if lift_obj(turns_till_doors_close) = 0
   write "The doors are already closed.^"
   set TIME = false
   return
endif
write "The lift doors slide closed.^"
execute "+lift_close"
}

object obutton: east eastern open door button control 1
 short		an "open doors button"

{press : move
if lift_obj(turns_till_doors_close) > 0
   write "The doors are already open.^"
   set TIME = false
   return
endif
if lift_obj(moving_to) != arrived
   write "The lift doors refuse to open while the lift is in motion.^"
   return
endif
write "The lift doors slide open.^"
execute "+lift_open"
}

object gbutton: ground floor button g
 short		a "ground floor button"
 floor		0

{press : move
execute +floorbuttonpress<self
}

object 1button: first floor button 1
 short		a "first floor button"
 floor		1

{press : move
execute +floorbuttonpress<self
}

object 2button: second floor button 2
 short		a "second floor button"
 floor		2

{press : move
execute +floorbuttonpress<self
}

object panel : panel of buttons
 short		a "panel of buttons"

{examine
write "The panel consists of five buttons labelled ground, one, two, "
write "open and close. "
if gbutton has ON
   write "The button for the ground floor is currently lit."
endif
if 1button has ON
   write "The button for the first floor is currently lit."
endif
if 2button has ON
   write "The button for the second floor is currently lit."
endif
write ^
execute examine_display
}

string led_display	G 1 2

object display : led display
 short		an "LED display"

{examine
write "Above the panel is an LED display with a large red '"
write led_display[lift_obj(floor)] "'.^"
}

# Elements of lift object:
constant floor						5
constant moving_to					6
constant arrived				        42; POSSIBLE VALUE OF moving_to
constant turns_till_doors_close 	                7
constant delta						8

object lift_obj: lift door doors
 short		name "east lift"
 moving_to	arrived

{examine
if lift_obj(turns_till_doors_close) > 0;
   write "The lift doors are open.^"
else
   write "The lift doors are closed.^"
endif
}

{enter
if here = lift
   write "You are already in the lift.^"
   set TIME = false
   return
endif
proxy "east"
}

{open
if lift_obj(turns_till_doors_close) > 0;
   write "The lift doors are already open.^"
   return
endif
if here = lift
   write "(by pressing the open doors button)^"
   proxy "press open doors button"
   return
endif
write "(by pressing the call button)^"
proxy "press call button"
}

{close
if lift_obj(turns_till_doors_close) = 0;
   write "The lift doors are already closed.^"
   break
endif
if here = lift
   write "(by pressing the close doors button)^"
   proxy "press close doors button"
   return
endif
write "There is no way to close the lift doors from the outside.^"
}

location first_floor : first floor
 short		the "first floor"
 has		OUTSIDE_LIFT
 down		ground_floor
 up		second_floor

{look
write "<You are on the first floor. The "
if here(north) != nowhere
   write "open "
else
   write "closed "
endif
print:
   door door to an elevator is to the north and a set of stairs lead up
   and down from here. Beside the door is a call button.^
.
}

{movement
if +door_warning = true
   return true
endif
return false
}

object callbutton1: call button
 short		a "call button"
 floor		1

location second_floor : second floor
 short		the "second floor"
 has		OUTSIDE_LIFT
 down		first_floor

{look
write "You are on the second floor. The "
if here(north) != nowhere
   write "open "
else
   write "closed "
endif
print:
   door door to an elevator is to the north and a set of stairs lead
   down. Beside the door is a call button.^
.
}

{movement
break +door_warning
break false
}

object callbutton2: call button
 short		a "call button"
 floor		2

{+lift_close
set lift_obj(turns_till_doors_close) = 0
set noun3 = FLOOR_MAPPING[lift_obj(floor)]
set lift(south) = nowhere
set lift(out) = nowhere
set lift(south) = nowhere
set lift(out) = nowhere
set noun3(in) = nowhere
set noun3(north) = nowhere
}

{+lift_open
set lift_obj(turns_till_doors_close) = 3;
set noun3 = FLOOR_MAPPING[lift_obj(floor)]
set lift(south) = noun3
set lift(out) = noun3
set noun3(in) = lift
set noun3(north) = lift
}

{+lift_action
if here = lift
   move lift_obj to here
endif
if here has OUTSIDE_LIFT
   move stairs to here
   move lift_obj to here
endif
if lift_obj(turns_till_doors_close) > 0
   # THE LIFT DOORS ARE OPEN...
   set lift_obj(turns_till_doors_close) - 1
   if lift_obj(turns_till_doors_close) = 0
      if here = lift : here = FLOOR_MAPPING[lift_obj(floor)]
         write "^The lift doors slide closed.^"
       endif
      execute "+lift_close"
   endif
   return # THE LIFT CAN'T DO ANYTHING ELSE UNTIL THE DOORS HAVE CLOSED
endif
if lift_obj(moving_to) != arrived
   if lift_obj(moving_to) != lift_obj(floor)
      # THE LIFT IS STILL ON ITS WAY TO SOMEWHERE
      set lift_obj(delta) = lift_obj(moving_to)
      set lift_obj(delta) - lift_obj(floor)
      if lift_obj(delta) < 0 
         set lift_obj(floor) - 1
      else
         set lift_obj(floor) + 1
      endif
      if here = lift
         write "^The lift vibrates as it slowly "
         if lift_obj(delta) < 0
            write "descends.^"
         else
            write "ascends.^"
         endif
      endif
      return
   endif
   set lift_obj(moving_to) = arrived
   if here = FLOOR_MAPPING[lift_obj(floor)]
      write "^A crisp-sounding bell rings briefly and the doors "
      write "to the lift slide open.^"
   endif
   if here = lift
      write "^Having arrived at the selected floor, the lift "
      write "gently comes to a halt and the doors open.^" 
   endif
   execute "+lift_open"
   execute "+disable_callbuttons"
endif
}

{+press_callbutton
if arg[0] has ON
   write "The call button has already been pressed.^"
   set TIME = false
   return
endif
if lift_obj(floor) = arg[0](floor)
   if lift_obj(turns_till_doors_close) > 0
      write "There is already a lift here.^"
      set TIME = false
      return
   endif
   write "A crisp-sounding bell rings briefly and the doors "
   write "to the lift slide open.^"
   execute "+lift_open"
   ensure arg[0] hasnt ON
   return
endif   
write "<p>As you press the call button it lights up.^"
ensure arg[0] has ON
set lift_obj(moving_to) = arg[0](floor)
}

{+disable_callbuttons
ensure gbutton hasnt ON
ensure 1button hasnt ON
ensure 2button hasnt ON
ensure callbuttong hasnt ON
ensure callbutton1 hasnt ON
ensure callbutton2 hasnt ON
}

{+door_warning
if COMPASS = north : COMPASS = in
   if destination = false
       write "The lift doors are closed.^"
       return
   endif
endif
return false
}

object kryten: myself self me
 has		ANIMATE
 short		name "yourself"
 quantity	50
 parent		ground_floor
 player

#include "verbs.library"