ernave 20 Posted February 15, 2019 Let's say that I want to set and read variables in the different parts of a trigger (the condition, the activation, and the deactivation section). Step 1, I give the trigger a name like MyTrigger Step 2, I set a variable in the activation section: MyTrigger setvariable ["somevarname",12345]; Step 3, I can read the variable in deactivation: MyTrigger getvariable ["somevarname",0] My question: can I do this without having to hard code "MyTrigger" in the code? Why do I want to do this? Because I will have many, many copies of this trigger in my mission, and I would prefer not to have to customize the code for all of them. Thanks. Share this post Link to post Share on other sites
opusfmspol 282 Posted February 15, 2019 (edited) thisTrigger is refence to the trigger itself in triggerStatements. No need to give the trigger a name unless needed for reference elsewhere. If you want the set variable unique to one trigger, give one trigger a name and there use thisTrigger setVariable [ ] and thisTrigger getVariable [ ]. In all the other triggers put <trigger name> getVariable [ ], using reference to that one trigger's name. Or, if you need the set variable unique to each trigger individually, no need to name the triggers. in each trigger use thisTrigger setVariable [ ] and thisTrigger getVariable [ ]. Edited February 15, 2019 by opusfmspol clarified Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted February 15, 2019 Why stick to triggers in the first place? You can easily define a more abstract function that does what you want and applies what you want on any game object. Cheers Share this post Link to post Share on other sites
ernave 20 Posted February 15, 2019 2 hours ago, opusfmspol said: thisTrigger is refence to the trigger itself So if I understand you correctly, this statement should work: thisTrigger getVariable["dfsd",0] Share this post Link to post Share on other sites
opusfmspol 282 Posted February 15, 2019 Yes. And 0 is returned if setVariable hasn't been done. Share this post Link to post Share on other sites
ernave 20 Posted February 15, 2019 Thank you! I guess I tried "this" but didn't try "thisTrigger" I notice another one of the magic variables is "thisList" - if I wanted to loop through that to see if any human player was still inside the trigger radius, would I do something like: { if (isPlayer _X) { // some code here } } foreach thisList Share this post Link to post Share on other sites
opusfmspol 282 Posted February 15, 2019 Yes, but since isPlayer could occasionally give a bad false return, (_x In allPlayers) might be better. Share this post Link to post Share on other sites