Jump to content
JoMiMi

Adding an action linked from another action

Recommended Posts

Hello. For the past hour or so I've tried to link an addaction to another addaction in the init field of a data terminal.
Here's my notes for that init section and the script.
 

//Add an action to a data terminal to open it
//When that action is activated by a player, it will add another action
//When that second action is activated, it will run an .sqf file that
//consists of the nopop variable

this addAction ["Startup Terminal", {[KillhouseControl,1] call BIS_fnc_dataTerminalAnimate;
this addAction ["Start Killhouse", targetup.sqf}]];
this addAction ["Shutdown Terminal", {[KillhouseControl,0] call BIS_fnc_dataTerminalAnimate;}];
//To-do: Remove action

First of all, is there anything I'm doing wrong?
Second of all, is there a way to do this?

Share this post


Link to post
Share on other sites

Heya!
 

I'm a little confused. It seems the control structures go in this order:
 

Startup Terminal ---> Start Killhouse (repeatable)

Shutdown Terminal <---> Startup Terminal


In which case, you could just add a removeAction line at the end of your KillHouseControl script for the Startup and Shutdown actions. In this case, Start Killhouse seems more like Reset Killhouse.  

It doesn't look like you need anymore addActions, just one more line of code to remove the action from the menu after it's completed. Or am I missing something?
 

Share this post


Link to post
Share on other sites
Spoiler

this addAction[ "Startup Terminal", {
	params[ "_target", "_caller", "_id", "_args" ];
	
	if !( _target getVariable[ "terminalStarted", false ] ) then {
		_target setVariable[ "terminalStarted", true ];
		_target setUserActionText[ _id, "Shutdown Terminal" ];
		[ KillhouseControl, 1 ] call BIS_fnc_dataTerminalAnimate;
		_target setVariable[ "startKillHouseAction", _target addAction[ "Start Killhouse", "targetup.sqf" ] ];
	}else{
		_target setUserActionText[ _id, "Startup Terminal" ];
		_target removeAction ( _target getVariable "startKillHouseAction" );
		[ KillhouseControl, 0 ] call BIS_fnc_dataTerminalAnimate;
		_target setVariable[ "terminalStarted", false ];
	};
	
}];

 

Then you will also want to manage the setVariable and action text for a MP environment if needed.

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

×