Little problem with a multi floor elevator

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
erick
Major
Posts: 280
Joined: Wed May 30, 2007 1:14 am
Location: USA

Little problem with a multi floor elevator

Post 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.
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

level.elepos

Post 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.
Tom Trude,

Image
User avatar
erick
Major
Posts: 280
Joined: Wed May 30, 2007 1:14 am
Location: USA

Post 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.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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.
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

script

Post 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.
Last edited by tltrude on Tue Aug 28, 2007 3:08 pm, edited 1 time in total.
Tom Trude,

Image
User avatar
erick
Major
Posts: 280
Joined: Wed May 30, 2007 1:14 am
Location: USA

Post 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
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

debug

Post 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!
Tom Trude,

Image
User avatar
erick
Major
Posts: 280
Joined: Wed May 30, 2007 1:14 am
Location: USA

Post by erick »

Cool! Actually, it is for a tutorial that I just finished on elevators. :D
Post Reply