Page 1 of 1

triggers

Posted: Sun Oct 12, 2003 11:33 am
by w0lv3
how do i set a trigger to be in a 3d box or a square area? theres nothing in g_allclasses about the area of a trigger... or is there? :?
and is it trigger_use that makes it so the player has to press the use button to trigger it? because i couldnt get it to work.... and without setting the area of a trigger it would be impossible to press use in the exact place...

Re: triggers

Posted: Sun Oct 12, 2003 12:41 pm
by Bjarne BZR
w0lv3 wrote:how do i set a trigger to be in a 3d box or a square area? theres nothing in g_allclasses about the area of a trigger... or is there? :?
and is it trigger_use that makes it so the player has to press the use button to trigger it? because i couldnt get it to work.... and without setting the area of a trigger it would be impossible to press use in the exact place...
You draw a box in Radiant, and make that box a trigger_use. That makes the trigger area.

And yes the trigger_use is the one you have to activate manually as a player.

Set the key/value setthread/any_label, and add

Code: Select all

any_label:
	// Your code to be exewcuted when the trigger is fired here
end
...to the script ( after the end of the main function ).

Does that answer your question?

Posted: Sun Oct 12, 2003 1:37 pm
by w0lv3
i meant without using mohradiant.... i got this much now:

local.trig = spawn trigger_use
local.trig.origin = ( x x x )
local.trig setsize ( 0 0 0 ) ( x1 y1 z1 ) ( x2 y2 z2 )

would that work? im too tired to even open mohaa right now :S

im confused about setsize though... why does there have to be 2 coordinates? like x1 and x2.... are they the corners of the area or what? and if they are then whats the point of the first numbers?

Posted: Sun Oct 12, 2003 2:00 pm
by Bjarne BZR
Ah, only scripting you say. Here is an example of pure scripting trigger:

Code: Select all

local.trigger = spawn trigger_use "setthread" "fire_flak88"
local.trigger.origin = ( 0.0 100.0 0.0 ) 
local.trigger setsize ( -50 -50 -50 ) ( 50 50 50 )
And you need this so the firing of the trigger has some method to call:

Code: Select all

fire_flak88:
	// Stuff to happen
end
The setsize command only uses 2 coordinates to define the extents of the box, so it cant be a box of any shape... just "box shaped" ;)

Hope it helps!

Posted: Sun Oct 12, 2003 2:12 pm
by w0lv3
yes that helped thanks :D

setthread

Posted: Sun Oct 12, 2003 7:59 pm
by w0lv3
"setthread" "fire_flak88"
fire_flak88:
// Stuff to happen
end


....it doesnt work :x
this is what i could get to work, tell me if theres a better method:


local.trigger targetname flak88
thread fire_flak88

fire_flak88:
$flak88 waittil trigger
//stuff to happen
thread fire_flak88
end

fine

Posted: Sun Oct 12, 2003 8:04 pm
by tltrude
That should work fine. Normally there are quotes around the targetname:

local.trigger targetname "flak88"

You can also write it as:

local.trigger.targetname = "flak88"

Also, I hope you realize the thread will loop endlessly, as it is now, untill it overloads and crashes the game. Just spotted another:

use "waittill" not "waittil".

Posted: Sun Oct 12, 2003 8:47 pm
by w0lv3
thats weird, this works:

Code: Select all

local.trigger setthread "fire_flak88"
and this doesnt work:

Code: Select all

local.trigger = spawn trigger_use "setthread" "fire_flak88"
... they should do the same thing :?

Yep

Posted: Sun Oct 12, 2003 9:55 pm
by tltrude
Yeah!, I have been having the same kind of problems with spawning. Have a look at this messy thread over at TMT:

http://www.modtheater.com/forum/showthread.php?t=11493

Posted: Sun Oct 12, 2003 11:13 pm
by nuggets
here is a script i have which spawns a trigger for random items... i would edit it so you could tell what's happening but that may compromise whether it works ot not

so...

to_steal_1:
level.to_steal = (randomint (level.variance2) + level.min2)
level.items_taken = 0
waitthread the_unhidden level.to_steal $to_steal 0 "scripts_of_nuggets/nuggets_random.scr::to_steal_2" "steal"
end

the_unhidden local.total local.item local.count local.setthread local.prefix:
if (local.total == 0)
{end}
if (local.total > local.item.size)
{iprintln_noloc "!!!ERROR, trying to choose " local.total " " local.item "s when only " local.item.size " exist!!!"
end}
if (local.total == local.item.size)
{for (local.i=1;local.i<=local.item.size;local.i++)
{local.item[local.i].here = 1}
goto which_to_hide local.item local.setthread local.prefix}
local.number = (randomint(local.item.size) + 1)
if (local.count == 0)
{for (local.i=1;local.i<=local.item.size;local.i++)
{if (local.item[local.i].here == 1)
{local.count++}}}
if !(local.item[local.number].here == 1)
{local.item[local.number].here = 1
local.count++
if (local.count == local.total)
{goto which_to_hide local.item local.setthread local.prefix}
else
{wait .001
goto the_unhidden local.total local.item local.count local.setthread local.prefix}}
else
{goto the_unhidden local.total local.item local.count local.setthread local.prefix}
end


which_to_hide local.item local.setthread local.prefix:
for (local.i=1;local.i<=local.item.size;local.i++)
{if (local.item[local.i].here == 0)
{local.item[local.i] hide
local.item[local.i] notsolid}
else
{level.item_name = (local.prefix + "_trigger_" + local.i)
spawn trigger_use "targetname" level.item_name "#item_num" local.i "setthread" local.setthread
level.item_name.origin = local.item[local.i].origin
level.item_name.angles = local.item[local.i].angles
level.item_name setsize (0 0 0) (8 8 4)
level.item_name.on = 0
level.item_name.parent = local.item[local.i]
local.item[local.i].triggername = level.item_name
level.item_name nottriggerable}}
end

as you can see i used setthread with quotes and it all works but no reason your's shouldn't

thanks!

Posted: Mon Oct 13, 2003 1:36 am
by tltrude
Thanks nuggets, your script makes me feel a lot better about mine being messy, lol. By the way, I cracked the "Explosive Crate Spawning" thread and it works great!!!

http://www.modtheater.com/forum/showthread.php?t=11493