ACE3/addons/interact_menu/functions/fnc_removeAction.sqf

53 lines
1.3 KiB
Plaintext
Raw Normal View History

/*
* Author: commy2
*
* Add an ACE action to an object. Note: This function is global.
*
* Argument:
* 0: Object the action should be assigned to (Object)
* 1: Entry to remove (Array or Number)
*
* Return value:
* ID of the action (used to remove it later).
*/
#include "script_component.hpp"
2015-01-19 04:13:45 +00:00
private ["_object", "_entry", "_found", "_actions", "_searchFnc"];
_object = _this select 0;
_entry = _this select 1;
if(!IS_OBJECT(_object)) exitWith {false};
_actions = _object getVariable [QUOTE(GVAR(actionData)), []];
if(IS_ARRAY(_entry)) then {
_entry = _entry select 7;
};
_found = false;
_searchFnc = {
2015-01-19 04:13:45 +00:00
private ["_actions", "_entry", "_childActions"];
_actions = _this select 0;
_entry = _this select 1;
{
if((_x select 7) == _entry) then {
_actions set[_forEachIndex, "aceactiondelete"];
_actions = _actions - ["aceactiondelete"];
_found = true;
} else {
if(!_found && {count (_x select 6) > 0}) then {
_childActions = [(_x select 6), _entry] call _searchFnc;
_x set[6, _childActions];
};
};
} forEach _actions;
_actions;
};
_actions = [_actions, _entry] call _searchFnc;
_object setVariable [QUOTE(GVAR(actionData)), _actions];
_found;