Jump to content
Sign in to follow this  
Valfunction

Multiple instances of addAction

Recommended Posts

I have an addAction script which may be executed multiple times on an object. This script places an additional addAction on the object as well.

*does someting*

_actionid = _object1 addAction ["Stuff", "stuff.sqf"];

Is there a way to check if _actionid has already been added to _object1 so that I don't get multiple instances of "Stuff" on my scroll wheel?

Share this post


Link to post
Share on other sites

not entirely sure but I think thats what the portion of the _id in the script is for as I've been experimenting w/ this also(bout to check as a matter of fact)

example:

_unit = _this select 0;
_target = _this select 1;
_id = _this select 2;

//assuming _unit and _target are defined
if (condition) then {_id = some function within the script;_action = _unit addAction ["name","_scriptName",true,true,1,(_this select 2 == something)]}

Share this post


Link to post
Share on other sites

_actionid can't have been already added. It always increment everytime you add an action, even if the action you had is the exact same that the one you did two seconds ago.

One good way to keep track of what you're doing with objects is to use setVariable.

_isAction = _target getVariable ["TAG_ActionAdded", false];   // checks if the action was already added, returns false as default.
if _isAction exitWith {};                                                   // gets out if the action was indeed added
_actionid = _object1 addAction ["Stuff", "stuff.sqf"];             // adds the action
_target setVariable ["TAG_ActionAdded", true];                    // remembers the action was added

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×