karl1206 10 Posted February 23, 2016 Hey i was wondering what the easiest way to check if a unit isn't within a trigger placed in editor via a script. i want it as a condition for a "if" command. thx in advance. :) Share this post Link to post Share on other sites
st_dux 26 Posted February 23, 2016 Hey i was wondering what the easiest way to check if a unit isn't within a trigger placed in editor via a script. i want it as a condition for a "if" command. thx in advance. :) You want to know if a unit is not in a trigger area? The easiest way is to use the special variable "thisList", which is an array accessible in the trigger code fields (condition, activation, deactivation) that contains every unit presently meeting the trigger detection criteria. If you want this information accessible in an external script, you can either call the script from your trigger, passing thisList as an argument, or you can set thisList to a global variable. For example, you could make a repeatable trigger with the criteria "Any -- Present" and the following code in both the activation and deactivation fields: var_myTriggerList = thisList Now the global variable "var_myTriggerList" will contain a list of everyone in your trigger's area, updated each time a unit enters or leaves. In your script, you could check against this with the following code to determine that a unit is not in the area: if (isNil "var_myTriggerList") then {var_myTriggerList = []}; if (!myUnit in var_myTriggerList) then {code} (The first line accounts for a situation where no unit has yet entered or left the trigger area, in which case the variable would not yet be defined). 3 Share this post Link to post Share on other sites
davidoss 552 Posted February 23, 2016 if ([trigger, unit] call BIS_fnc_inTrigger) then { }; or if (["marker", unit] call BIS_fnc_inTrigger) then { }; negative if !([trigger, unit] call BIS_fnc_inTrigger) then { }; or if !(["marker", unit] call BIS_fnc_inTrigger) then { }; 1 Share this post Link to post Share on other sites