dreadedentity 278 Posted September 11, 2014 So I have this script, "Init.sqf". _first = player addAction ["Get second option", { _second = player addAction ["Get first option", { player removeAction _this select 3 select 0; null = [] execVM "Init.sqf"; }, _second, 6, true, true]; player removeAction _this select 3 select 0; }, _first, 6, true, true]; hint format ["%1", _first]; It's pretty straightforward, you use an action, it gets removed, and a new action appears. If you use that one then it gets removed and the first option is shown again. Then repeat. However, every time I make a change I either get "Error: Type Array, Number expected" or "Undefined variable in expression _first". Is passing an argument even implemented? Also, has anybody else noticed general wonkiness while using addAction or does it just seem weird since I'm not familiar with the command? Share this post Link to post Share on other sites
kbbw123 115 Posted September 11, 2014 try typing in on the top: private ["_first","_second","_this"]; this should define the variable. atleast this is wat works for me when i'm using local variable's. 1 Share this post Link to post Share on other sites
654wak654 25 Posted September 11, 2014 (edited) _this select 3 select 0 isn't needed. _this select 3 will be equal to _first or _second AFAIK, since you're not passing multiple arguments. Also you should put [_first] or ["_first"] in the addAction instead of _first. Not sure which one right now. You don't even need that when you can just remove the action itself by removing _this select 2, because _this select 2 returns the action it self. To explain it more (if you still need it) I'm gonna give an example. Here is how I do On/Off actions with a file called "actionManager.sqf": Make sure the have a Boolean value defined before (or while) you're calling it: wakCond = false; actionManager.sqf: (_this select 0) removeAction (_this select 2); //This is where you have your problem btw ;), can't use array components like that, at least not in ArmA _player = _this select 1; if (wakCond) then { //Code _player addAction ["Turn it off", "actionManager.sqf"]; //It doesn't have to be anything special. wakCond = false; //Next time it'll hit the other scope } else { //Code _player addAction ["Turn it on", "actionManager.sqf"]; //It doesn't have to be anything special. wakCond = true; //Next time it'll hit the other scope }; Alternatively you could pass wakCond through the addAction but for me this method feels like I have more control, you can still do it your way. You only have syntax errors. Edited September 11, 2014 by 654wak654 Share this post Link to post Share on other sites
Larrow 2823 Posted September 12, 2014 An action that toggles itself actionStatus = false; player addAction ["Turn On", { if (!actionStatus) then { hint "You have turned it On"; (_this select 0) setUserActionText [(_this select 2), "Turn Off"]; }else{ hint "You have turned it Off"; (_this select 0) setUserActionText [(_this select 2), "Turn On"]; }; actionStatus = !actionStatus; },[],1,true,true,"",""]; One action, no messing with adding and removing. Share this post Link to post Share on other sites
654wak654 25 Posted September 12, 2014 setUserActionText existed?! I tried to set my action's name by giving it a string variable back at some time... It was here since alpha too... AFK Share this post Link to post Share on other sites
dreadedentity 278 Posted September 12, 2014 @654wak654 I had already tried all of your recommendations, couldn't get anything to work. Also you don't need to pass an array for arguments, addAction can take any value in it's 3rd argument. But I forgot about _this select 2, I guess I wasn't paying enough attention when I read the documentation. Luckily, Larrow has come to the rescue yet again. @Larrow Thanks! Share this post Link to post Share on other sites