ACE3/addons/interact_menu/functions/fnc_removeAction.sqf

51 lines
1.2 KiB
Plaintext
Raw Normal View History

/*
2015-02-21 20:11:03 +00:00
* Author: commy2 and NouberNou
* Remove an action from an object
*
* Argument:
2015-02-21 20:11:03 +00:00
* 0: Object the action should be assigned to <OBJECT>
* 1: Entry to remove <ARRAY> or <NUMBER>
*
* Return value:
2015-02-21 20:11:03 +00:00
* None
*
* Public: No
*/
#include "script_component.hpp"
2015-02-21 20:11:03 +00:00
EXPLODE_2_PVT(_this,_object,_entry);
2015-02-21 20:11:03 +00:00
private ["_found", "_actions", "_searchFnc"];
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];
2015-02-21 20:11:03 +00:00
_found;