elevator tutorial by Erick
Posted: Sun Sep 02, 2007 7:27 pm
Followed the instructions for the multiple floor elevator, but once in game the elevator goes to the second floor and back to the first floor without stopping. I named all my stuff according to the tut. Here is the script:
Anyone know where I might have gone wrong?
Thanks
Code: Select all
main:
exec global/ai.scr
exec global/cardgame.scr
exec global/door_locked.scr::lock
level waittill prespawn
$down_switch bind $elevator_cab // binds switches to elevator
$up_switch bind $elevator_cab
$down_trigger bind $down_switch// binds triggers to switches
$up_trigger bind $up_switch
//$elevator_cab movedown 8 //This was throwing my cab off
//$elevator_cab time 0
//$elevator_cab move
$elevator_cab speed 64 // sets speed to 64 units/s
level.elepos = 1 // starts on floor 1
$elevator_cab2 speed 64
level.script = "maps/untitled.scr"
level waittill spawn
$player item weapons/colt45.tik
$player useweaponclass pistol
thread elevator_prep
end
elevator_prep:
thread movedown
thread moveup
end
movedown:
$down_trigger waittill trigger// waits until the player triggers the trigger
if (level.elepos == 1)// if the elevator is on floor 1 then end because it cant go down anymore
end
$up_trigger nottriggerable // turns off the triggers until the elevator is done moving
$down_trigger nottriggerable
local.position = level.elepos // sets another variable
$down_switch anim turn //turns the switch
$elevator_cab loopsound lighthouse_run // makes some noise
$elevator_cab moveto $("floor" + (local.position - 1)) // move to the floor below the one that it is on
$elevator_cab waitmove
$elevator_cab stoploopsound
$down_switch anim idle
level.elepos--
$down_trigger triggerable // turns the triggers back on
$up_trigger triggerable
goto elevator_prep
end
moveup:
$up_trigger waittill trigger
if (level.elepos == 5)// if the elevator is at the top then end because it cant go up anymore
end
$down_trigger nottriggerable
$up_trigger nottriggerable
local.position = level.elepos
$up_switch anim turn
$elevator_cab loopsound lighthouse_run
$elevator_cab moveto $("floor" + (local.position + 1))
$elevator_cab waitmove
$elevator_cab stoploopsound
$up_switch anim idle
level.elepos++
$up_trigger triggerable
$down_trigger triggerable
goto elevator_prep
end
Thanks