Page 1 of 1
how do i tell if player has hit a trigger - not waittill
Posted: Sat Feb 11, 2006 11:10 pm
by HDL_CinC_Dragon
In my script i need to be able to tell when a player has hit a trigger WITHOUT using waittill
i want it to be something along the lines of this:
Code: Select all
thread the_Thread:
while(1)
{
if ($trigger_01 isDown) // Is isDown even a statement?
{
level.floor_circ = 2
}
waitframe
}
end
This obviously isnt going to be the whole thread but i want you to just get the idea of what i mean. Can anyone help?
the_Thread
Posted: Sat Feb 11, 2006 11:29 pm
by tltrude
OK, using the word "thread" and the the threads name at the top of the script will make the game run that thread. If it has a waittill line, it will stop running untill the trigger event happens in the game. But, you probably know all that.
There are other ways to tell the game to run the thread named "the_Thread". In the properties of a trigger (key N) you can add this.
Key: setthread
Value: the_Thread
when someone fires the trigger, "the_Thread" will run. So now, you no longer need "thread the_Thread" at the top of the script or the waittill line in the thread.
Hope that helps.
Posted: Tue Feb 14, 2006 12:10 am
by LeBabouin
tltrude, could you please provide an example, cos i don't get it, sorry. Thanks in advance.
Thread
Posted: Tue Feb 14, 2006 12:23 am
by tltrude
Using "The_thread" as the name of a thread is kind of dumb, but what part do you not get?
Posted: Tue Feb 14, 2006 3:12 pm
by HDL_CinC_Dragon
ok let me explain something.
When i type a sample code to get my point accross, I dont give threads and variables actual names. I just give them names that let you know that that thing is a trigger, a door, an elevator, a random little box floating around, etc etc. unless i say, "here is what my code is" then the code that i post is not exactly what i have. So please stop saying "well if you name it that then ..." when i post an example. Thanks
that being said, here is an example code
Code: Select all
theThreadName:
while(1)
? ?{
? ? ? if (local.player hasHit $trigger01) // my question is what do i need to replace hasHit with to see if the player hit the trigger
? ? ? ? ?{
? ? ? ? ? ? iprintln "You hit the trigger"
? ? ? ? ?}
? ? ? waitframe
? ?}
end
istouching
Posted: Tue Feb 14, 2006 4:21 pm
by tltrude
istouching
Posted: Tue Feb 14, 2006 10:14 pm
by HDL_CinC_Dragon
even if its a trigger>use? i thought isTouching was only for triggerMulitples
Posted: Wed Feb 15, 2006 6:15 am
by tltrude
ok, let me try this again.
There are other ways to tell the game to run your thread. In the properties of the trigger_use (
highlight the trigger and press key N) you add a key and value.
Key:
setthread
Value:
thethreadname
when a player hits his use key near the trigger, your thread will start. So now, you no longer need to start the thread at the top of the script or use a waittill line--the trigger does it all by itself.
Code: Select all
thethreadname:
iprintln "A player has hit the trigger."
end
Posted: Thu Feb 16, 2006 1:37 am
by GiffE1118
if its a spawned trigger u can do the same
spawn trigger_multiple targetname trigger
$trigger setthread thethreadname
$trigger setsize ( 0 0 0 ) ( 0 0 0 )
end
thethreadname:
iprintln "A player has hit the trigger."
end
Posted: Thu Feb 16, 2006 5:27 pm
by HDL_CinC_Dragon
Alright, thanks guys, ill use setthread.
Posted: Sat Feb 18, 2006 2:43 am
by LeBabouin
tltrude wrote:
Key: setthread
Value: thethreadname
That's what i don't get. Is it for scripting or mapping?
Mapping
Posted: Sat Feb 18, 2006 6:32 am
by tltrude
It is mapping. You highlight the trigger in the editor and press key N to bring up the "ENTITY" screen. At the bottom of that screen you can type in a key/value and hit Enter. To close the screen, hit N again. The map will have to be compiled for it to work.
GiffE1118 said, you can add a setthread right in the script, but I don't know if that works or not.