Trigger use, for only axis...
Moderator: Moderators
-
chrisjbooth2001
- Colour Sergeant
- Posts: 77
- Joined: Thu Dec 18, 2003 12:57 am
Trigger use, for only axis...
how would i make a trigger use, so only axis could use it?
So far ive got this...
//------------------------------------------
axis_switch:
//------------------------------------------
$axis1 thread axisdoor
Jvmap told me this but i dunno how to incorporate it to the scripts...
if(parm.other.dmteam == axis)
So far ive got this...
//------------------------------------------
axis_switch:
//------------------------------------------
$axis1 thread axisdoor
Jvmap told me this but i dunno how to incorporate it to the scripts...
if(parm.other.dmteam == axis)
-
dcoshea
- Colour Sergeant
- Posts: 94
- Joined: Thu Mar 04, 2004 3:00 am
- Location: Sydney, Australia
- Contact:
Re: Trigger use, for only axis...
I assume the trigger_use has its 'setthread' property set to 'axis_switch' so that 'axis_switch' is called/executed when the trigger is USEd?chrisjbooth2001 wrote:how would i make a trigger use, so only axis could use it?
So far ive got this...
//------------------------------------------
axis_switch:
//------------------------------------------
$axis1 thread axisdoor
Jvmap told me this but i dunno how to incorporate it to the scripts...
if(parm.other.dmteam == axis)
Anyway, assuming axis_switch is being called somehow, this will make it only call axisdoor when it's an Axis player who hit the "switch":
Code: Select all
//------------------------------------------
axis_switch:
//------------------------------------------
if (parm.other.dmteam == "axis") {
$axis1 thread axisdoor
}
endRegards,
David
-
chrisjbooth2001
- Colour Sergeant
- Posts: 77
- Joined: Thu Dec 18, 2003 12:57 am
-
chrisjbooth2001
- Colour Sergeant
- Posts: 77
- Joined: Thu Dec 18, 2003 12:57 am
-
chrisjbooth2001
- Colour Sergeant
- Posts: 77
- Joined: Thu Dec 18, 2003 12:57 am
-
dcoshea
- Colour Sergeant
- Posts: 94
- Joined: Thu Mar 04, 2004 3:00 am
- Location: Sydney, Australia
- Contact:
Assuming the trigger's targetname is "bob", you'd use:chrisjbooth2001 wrote:I love the little comments lol,
How?
Code: Select all
$bob setthread axis_switchCode: Select all
$bob thread my_fake_setthread
my_fake_setthread:
while (1) { // loop forever
self waittill trigger // wait until the trigger is triggered
self thread axis_switch // call the thread
}
endInstead of using 'setthread', you could just use 'waittill trigger' in your code if you like.
Regards,
David
-
chrisjbooth2001
- Colour Sergeant
- Posts: 77
- Joined: Thu Dec 18, 2003 12:57 am
-
dcoshea
- Colour Sergeant
- Posts: 94
- Joined: Thu Mar 04, 2004 3:00 am
- Location: Sydney, Australia
- Contact:
If you were using the "this is how setthread works" code I posted:chrisjbooth2001 wrote:Ok, if i use the setthread method.. How would i make it so you trigger the thread, and once the thread finishes it allows ya to reuse it..
I think the command is waitthread ?
Code: Select all
$bob thread my_fake_setthread
my_fake_setthread:
while (1) { // loop forever
self waittill trigger // wait until the trigger is triggered
self thread axis_switch // call the thread
}
endHowever, you asked about doing this with 'setthread'. 'waitthread' won't help you directly, although in your case since the axis_switch thread calls the axisdoor thread, it will be needed. The game will call the thread that 'setthread' points to every time the trigger is triggered (as far as I know), and it's up to you to prevent concurrent calls if you don't want them. Try something like this:
Code: Select all
axis_switch:
if (level.axis_switch_thread_active) {
// we are already running this thread, don't run it again
end
}
level.axis_switch_thread_active = 1
// call using waitthread instead of thread so that we know when it's done
$axis1 waitthread] axisdoor
// axisdoor is done, so we're done, and we can set the flag indicating we're active back to 0, allowing this thread to execute again
level.axis_switch_thread_active = 0
endOf course, if you think about it, if two copies of that thread were called simultaneously and executed in a truly parallel fashion, they could both check level.axis_switch_thread_active at the same time, both see it's not set, then both set it simultaneously, thus both running 'axisdoor' at the same time, but I don't believe the game really runs threads with that level of concurrency - I think it will only run another thread when the thread it is currently running gets to a 'wait' statement.
I'm thinking co-operative/non-pre-emptive multi-tasking, in case there's anyone who knows exactly what I'm thinking and happens to know that I'm wrong
Regards,
David
-
chrisjbooth2001
- Colour Sergeant
- Posts: 77
- Joined: Thu Dec 18, 2003 12:57 am
