how do i tell if player has hit a trigger - not waittill

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

how do i tell if player has hit a trigger - not waittill

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

the_Thread

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

Image
LeBabouin
Lance Corporal
Posts: 22
Joined: Tue Jun 21, 2005 11:10 pm

Post by LeBabouin »

tltrude, could you please provide an example, cos i don't get it, sorry. Thanks in advance.
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Thread

Post by tltrude »

Using "The_thread" as the name of a thread is kind of dumb, but what part do you not get?
Tom Trude,

Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

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

istouching

Post by tltrude »

istouching
Tom Trude,

Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

even if its a trigger>use? i thought isTouching was only for triggerMulitples
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

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

Image
GiffE1118
Warrant Officer
Posts: 137
Joined: Fri Aug 05, 2005 12:14 am
Contact:

Post 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
www.95thDivision.com
Image

BOTTOM 125th Poster! lol
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

Alright, thanks guys, ill use setthread.
Image
LeBabouin
Lance Corporal
Posts: 22
Joined: Tue Jun 21, 2005 11:10 pm

Post by LeBabouin »

tltrude wrote:

Key: setthread
Value: thethreadname
That's what i don't get. Is it for scripting or mapping?
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Mapping

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

Image
Post Reply