Home   Help Search Login Register  

Author Topic: How to find out who activated a trigger.  (Read 1685 times)

0 Members and 1 Guest are viewing this topic.

Offline Captain Crunch

  • Members
  • *
How to find out who activated a trigger.
« on: 20 Apr 2007, 11:26:53 »
Hi people,

I made a trigger named Buster, activated by Independent present detected by west with axis of 300 by 200. Now when the trigger is activated, a SAD waypoint of an enemy group is created. I would like to SetPos the SAD waypoint around the spot where the Independent was seen. I don't remember the correct syntax.
In a another trigger which is activated by the Buster trigger, I have this in the Init field:

Code: [Select]
_Target = List Buster; WP = EGrp6 AddWaypoint [Position _Target, 3];
It doesn't work. I think it might just be some missing "" or () somewhere.  :cool2: I have no idea!

For the first part I get no error message, but for the waypoint positioning, I get this error message:

"Local variable in global space."

Can somebody help me out? Thank You.
Back to the forest!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: How to find out who activated a trigger.
« Reply #1 on: 20 Apr 2007, 11:32:39 »
I understand Buster is the name of the trigger and the following is going to its activation field:
Code: [Select]
target = List Buster select 0; WP = EGrp6 AddWaypoint [Position Target, 3];

Offline Captain Crunch

  • Members
  • *
Re: How to find out who activated a trigger.
« Reply #2 on: 20 Apr 2007, 11:44:07 »
Yes, this works perfectly. Thank You Mandoble.

Could I use the same code in two different triggers? I mean:

Code: [Select]
Target = List Buster Select 0; WP = EGrp6 AddWaypoint [Position Target, 3];
...Or must I use this previous code in one trigger and the following code in the other trigger?

Code: [Select]
target = List Buster select [color=red]1[/color]; WP = EGrp6 AddWaypoint [Position Target, 3];
Back to the forest!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: How to find out who activated a trigger.
« Reply #3 on: 20 Apr 2007, 13:02:11 »
Well, as said, Buster is the name of a trigger, so "list Buster" returns the list of units present in Buster's trigger's area.
you may change Buster by this, so it refers to current trigger instead of a particular one.

Note that target variable is global, so if you have three triggers checking for the same type of condition and with the same on Activation code, there may be interferences if two of them activate at the very same time.

If you dont want to mess up with globals, you may just create a simple script this way:
Code: [Select]
;weirdscript.sqs
_trigger = _this select 0
_list = list _trigger
? count _list == 0:exit

_target = list _trigger select 0
_wp = EGrp6 AddWaypoint [getPos _target, 3]
exit

in the activation code of the triggers [this]exec"weirdscript.sqs"

Offline RaymondLu

  • Members
  • *
Re: How to find out who activated a trigger.
« Reply #4 on: 24 Apr 2007, 09:10:11 »
Hi people,

I made a trigger named Buster, activated by Independent present detected by west with axis of 300 by 200. Now when the

onAct:     target=thislist select 0;WP = EGrp6 AddWaypoint [Position target, 3];

thislist select 0       is the 1st one activates the trigger.