Page 1 of 1

Little problem with a multi floor elevator

Posted: Mon Aug 20, 2007 1:21 am
by erick
I have had a problem that I have never had before. I am making an elevator that has multiple floors but the script doesnt seem to work. There are no errors in the console. Could someone help?

Code: Select all

movedown:

if (level.elepos == 1)
end

$elevator_cab speed 64

$down_trigger nottriggerable

local.position = level.elepos
	$down_switch anim turn
	
	$elevator_cab loopsound lighthouse_run
		$elevator_cab moveto $("floor" + (local.position - 1))
		$elevator_cab waitmove
	$elevator_cab stoploopsound
	
	$down_switch anim idle
		level.elepos--
			$down_trigger triggerable

end

moveup:

if (level.elepos == 5)
end

$elevator_cab speed 64

$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

end
the headings (moveup & movedown) are setthreads on triggers that dont work. Somehow the game doesnt see the triggers or something.
My game is a little messed up that might be the problem
The computer doesnt see mohaa as installed but I can still play it and a whole bunch of other junk. So I need to reinstall the game but I dont have disc 2 and so on.

level.elepos

Posted: Mon Aug 20, 2007 5:42 am
by tltrude
Here are some good lines to "debug" your triggers.

iprintlnbold_noloc "Down trigger has been used!"
iprintlnbold_noloc "Up trigger has been used!"

If you add them to the top of your threads, the message will tell you if the setthread worked. You can also use the same kind of message printing line to say what a variable is equal to at any point in the script.

iprintlnbold_noloc "level.elepos = " (level.elepos)
iprintlnbold_noloc "local.position = " (local.position)

My guess is that level.elepos will equal "NIL" (no value) because it starting value was not set (in prespawn) before it was used. So, NIL - 1 will end up as "$floor-1" and not "$floor4".

For example -

level waittill prespawn
level.elepos = 5


Also, you can move "$elevator_cab speed 64" to prespawn because it only needs to be set one time. And, you should make both triggers "nottriggerable" until the elevator stops moving, up and down.

Posted: Mon Aug 20, 2007 6:11 pm
by erick
I used the debug lines and none of them printed. The triggers dont seem to be firing. I think it has something to do with my game. I had the level.elepos = 1 after prespawn and before spawn but nothing happened. Again no errors in the console.

Posted: Tue Aug 28, 2007 10:32 am
by jv_map
Is this your entire script? If it is, the error is unsurprising, since the game starts reading the script right from the top, i.e. the movedown thread is fired right away (simply because it is the first thread in the file) and then sets $down_trigger nottriggerable prohibiting any further use of the trigger. I would suggest starting your script with a somewhat hideous 'end' line.

script

Posted: Tue Aug 28, 2007 2:59 pm
by tltrude
Copy and paste your entire script here. Is the rest of the script working? What is the name of your .bsp file and your .scr file? Are they both in the same folder? -- maps/dm?

You may want to recheck the setthread key/values.

Key: setthread
Value: movedown

Key: setthread
Value: moveup

Make sure the triggers are "trigger_use" entities.

Posted: Tue Aug 28, 2007 3:07 pm
by erick
Guys I found out the problem. It wasnt the script. I accidently put trigger multiples instead of trigger uses. The script works superb now! :D

debug

Posted: Tue Aug 28, 2007 3:11 pm
by tltrude
Cool, well at least you learned how to "debug" a script with messages! You can also add messages right in the trigger itself.

Key: message
Value: Moving down!

Posted: Tue Aug 28, 2007 4:28 pm
by erick
Cool! Actually, it is for a tutorial that I just finished on elevators. :D