Page 1 of 1

Lift Location

Posted: Fri Apr 02, 2004 12:51 am
by fuhrer
In my lift i have a display which tells u which floor the lift is on, however it only shows u the floor once the lift has stopped, i want it to show me which floor it is on as the lift passes thru it

i.e. if its moving from floor 1 to floor 4 the display will show 2 as it passes thru floor 2, then 3 as it moves thru floor 3.

script:

Code: Select all

call: 
	
	$inner_triggers nottriggerable		// turns off the triggers
	$outer_triggers nottriggerable
	$call_buttons playsound click			
	$call_buttons moveNorth 1		// moves buttons
	$call_buttons move
	wait .2
	$call_buttons moveSouth 1
	$call_buttons move
	if(level.doorpos == 1)
	{
	$left_door moveEast 78
	$right_door moveWest 78
	$left_door move
	$right_door move
	level.doorpos = 0
	}
	$("pos_" + $lift.floor) moveNorth 2
	$("pos_" + $lift.floor) move
	$("doors_" + $lift.floor) playsound lift_gate 	
	$("doors_" + $lift.floor) doclose 	
	$lift moveto $("floor_" + self.floor)
	$lift loopsound lift_sound
	$lift waitmove				// moves the lift to that destination
	$lift.floor = self.floor
	$lift loopsound lift_sound wait
	$left_door moveWest 78
	$right_door moveEast 78
	$left_door move
	$right_door move
	level.doorpos = 1
	$("pos_" + self.floor) moveSouth 2
	$("pos_" + self.floor) move
	$("doors_" + self.floor) doopen
	$("doors_" + self.floor) playsound lift_gate
	level.doors = $("doors_" + self.floor)
	wait 1.5
	$inner_triggers triggerable			// turns triggers on
	$outer_triggers triggerable

end

Posted: Fri Apr 02, 2004 12:53 am
by fuhrer
forgot to mention, pos_ is the name of the display, 1 thru 4... they move out thru the wall.

$("pos_" + $lift.floor) moveNorth 2

Posted: Fri Apr 02, 2004 2:20 am
by nuggets
explain why you have more than one indicator and your using
$("pos_" + $lift.floor)

i don't understand why you want different targetnames again for your indicator?

Posted: Fri Apr 02, 2004 4:05 am
by fuhrer
i have roman numerals that move out thru the wall when the lift is on a certain floor, all the number ones are named pos_1, 2 2 etc etc...

so when the lift is on floor 1, the numeral 1 will show up thru the wall on every floor.

i couldnt figure out with the script as it is, how to get a rotating dial to work.

Re: Lift Location

Posted: Sun Apr 04, 2004 3:40 am
by nuggets
the only way i can think without revamping your script a lot is to add a 2nd thread that checks which waypoint is closest,

you'll need

Code: Select all

floor_check:
	if (vector_length ($lift.origin - $("floor_" + $lift.floor).origin) > (vector_length ($lift.origin - $("floor_" self.floor + ($lift.floor + 1).origin)
	{
		//change indicator for going up
	}
	if (vector_length ($lift.origin - $("floor_" + $lift.floor).origin > (vector_length ($lift.origin - $("floor_" self.floor + ($lift.floor - 1).origin)
	{
		//change indicator for going down
	}
	if ($lift.moving == 1)
	{
		wait 1
		goto floor_check
	}
end

call: 
	thread floor_check	
	$lift.moving = 1
	$inner_triggers nottriggerable		// turns off the triggers
	$outer_triggers nottriggerable
	$call_buttons playsound click			
	$call_buttons moveNorth 1		// moves buttons
	$call_buttons move
	wait .2
	$call_buttons moveSouth 1
	$call_buttons move
	if(level.doorpos == 1)
	{
	$left_door moveEast 78
	$right_door moveWest 78
	$left_door move
	$right_door move
	level.doorpos = 0
	}
	$("pos_" + $lift.floor) moveNorth 2
	$("pos_" + $lift.floor) move
	$("doors_" + $lift.floor) playsound lift_gate 	
	$("doors_" + $lift.floor) doclose 	
	$lift moveto $("floor_" + self.floor)
	$lift loopsound lift_sound
	$lift waitmove				// moves the lift to that destination
	$lift.floor = self.floor
	$lift.moving = 0
	$lift loopsound lift_sound wait
	$left_door moveWest 78
	$right_door moveEast 78
	$left_door move
	$right_door move
	level.doorpos = 1
	$("pos_" + self.floor) moveSouth 2
	$("pos_" + self.floor) move
	$("doors_" + self.floor) doopen
	$("doors_" + self.floor) playsound lift_gate
	level.doors = $("doors_" + self.floor)
	wait 1.5
	$inner_triggers triggerable			// turns triggers on
	$outer_triggers triggerable

end

Posted: Tue Apr 06, 2004 2:29 am
by fuhrer
so how do i know which indicator to show? i went thru some calculations of ur thread, and the statement is always true for starters. (intended)

for this example the lift is on the 2nd floor, and is being called to the 4th.

Code: Select all

if (vector_length ($lift.origin - $("floor_" + $lift.floor).origin) > (vector_length ($lift.origin - $("floor_" self.floor + ($lift.floor + 1).origin) 
   { 
      //change indicator for going up 
   } 
   
if (vector_length (2 - (2)) > (vector_length (2 - (4 + (2 + 1)) 

if 0 > -5
   { 
     //sorry im lost
   } 
   
not sure which indicators to move, i have to move one in and one out...

:?