Jump to content
Sign in to follow this  
igneous01

Create nested addaction menu

Recommended Posts

Ive been thinking of how to approach this for a sleep script i made. i basically have the main action "Sleep", once its used, another list of actions will come up such as

Sleep 1 hour

Sleep 2 hours... etc etc

Cancel

Ive tried using Curry's action script, but it doesnt look like it will work within the initial script, because the variable that checks whether an action was pressed doesnt get updated in the script itself.

_id = _this select 0;
_sleepanim = "AidlPpneMstpSnonWnonDnon_SleepA_sleep2";
_wakeupanim = "AidlPpneMstpSnonWnonDnon_SleepC_standUp";
_timer = 0;
_actionpressed = 0;

player addAction ["Sleep 1 Hour","gen_action.sqf","_timer = 1; _actionpressed = 1"];
player addAction ["Sleep 2 Hour","gen_action.sqf","_timer = 2; _actionpressed = 1"];
player addAction ["Sleep 3 Hour","gen_action.sqf","_timer = 3; _actionpressed = 1"];
player addAction ["Sleep 4 Hour","gen_action.sqf","_timer = 4; _actionpressed = 1"];
player addAction ["Sleep 5 Hour","gen_action.sqf","_timer = 5; _actionpressed = 1"];
player addAction ["Sleep 6 Hour","gen_action.sqf","_timer = 6; _actionpressed = 1"];
player addAction ["Cancel","gen_action.sqf","_actionpressed = 2"];

waitUntil {_actionpressed != 0};
if (_actionpressed == 1) then {
   // main loop
   player playmove _sleepanim;
   sleep 8;
   titleText ["", "BLACK OUT", 5];
   sleep 5;
   skipTime _timer;
   titleText ["", "WHITE IN", 5];
   sleep 1;
   player switchmove _wakeupanim;
   waitUntil {animationState player != _wakeupanim};
   player switchmove "";
};

if (_actionpressed == 2) exitwith {};

if (_actionpressed > 2) then {
   hint "Error in Sleep Script, _actionpressed has unknown value";
};

Im thinking its because im using local variables, but the genAct script should only convert it as code? i dont think it matters whether its local or not in this case.

Even so, are there any suggestions or solutions to this?

---------- Post added at 22:51 ---------- Previous post was at 20:58 ----------

nevermind, turns out it was because of local variables being used. managed to get it to work now. now i just have to figure out how to remove the actions....

Share this post


Link to post
Share on other sites

If you get this to work would you please report back and post the script? It's something I would be interested n using.

Share this post


Link to post
Share on other sites

To remove actions you first have to name your action so it would look something like this:

sleep1 = player addAction ["Sleep 1 Hour","gen_action.sqf","_timer = 1; _actionpressed = 1"];

Then to remove it you would put:

player removeAction sleep1

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  

×