mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #686 from acemod/modifiableActions
Allow to dynamically modify actions at runtime.
This commit is contained in:
commit
4a76b0e5c9
@ -22,6 +22,13 @@ private ["_target","_player","_fullPath","_activeChildren","_dynamicChildren","_
|
||||
_target = _object;
|
||||
_player = ACE_player;
|
||||
|
||||
// Check if the function should be modified first
|
||||
if !((_origActionData select 10) isEqualTo {}) then {
|
||||
// It should, so make a copy and pass it to the modifierFunction
|
||||
_origActionData = +_origActionData;
|
||||
[_target, ACE_player, _origActionData select 6, _origActionData] call (_origActionData select 10);
|
||||
};
|
||||
|
||||
// Return nothing if the action itself is not active
|
||||
if !([_target, ACE_player, _origActionData select 6] call (_origActionData select 4)) exitWith {
|
||||
[]
|
||||
|
@ -27,7 +27,7 @@ if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
|
||||
private "_recurseFnc";
|
||||
_recurseFnc = {
|
||||
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_selection", "_condition", "_showDisabled",
|
||||
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren"];
|
||||
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren", "_modifierFunction"];
|
||||
EXPLODE_1_PVT(_this,_actionsCfg);
|
||||
_actions = [];
|
||||
|
||||
@ -56,6 +56,7 @@ _recurseFnc = {
|
||||
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
|
||||
|
||||
_insertChildren = compile (getText (_entryCfg >> "insertChildren"));
|
||||
_modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
|
||||
|
||||
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
|
||||
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
|
||||
@ -76,7 +77,8 @@ _recurseFnc = {
|
||||
[],
|
||||
_selection,
|
||||
_distance,
|
||||
[_showDisabled,_enableInside,_canCollapse,_runOnHover]
|
||||
[_showDisabled,_enableInside,_canCollapse,_runOnHover],
|
||||
_modifierFunction
|
||||
],
|
||||
_children
|
||||
];
|
||||
|
@ -27,7 +27,7 @@ if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
|
||||
private "_recurseFnc";
|
||||
_recurseFnc = {
|
||||
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_selection", "_condition", "_showDisabled",
|
||||
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren"];
|
||||
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren", "_modifierFunction"];
|
||||
EXPLODE_1_PVT(_this,_actionsCfg);
|
||||
_actions = [];
|
||||
|
||||
@ -46,6 +46,7 @@ _recurseFnc = {
|
||||
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
|
||||
|
||||
_insertChildren = compile (getText (_entryCfg >> "insertChildren"));
|
||||
_modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
|
||||
|
||||
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
|
||||
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
|
||||
@ -66,7 +67,8 @@ _recurseFnc = {
|
||||
[],
|
||||
[0,0,0],
|
||||
10, //distace
|
||||
[_showDisabled,_enableInside,_canCollapse,_runOnHover]
|
||||
[_showDisabled,_enableInside,_canCollapse,_runOnHover],
|
||||
_modifierFunction
|
||||
],
|
||||
_children
|
||||
];
|
||||
|
@ -14,6 +14,7 @@
|
||||
* 7: Position (Position or Selection Name) <POSITION> or <STRING> (Optional)
|
||||
* 8: Distance <NUMBER> (Optional)
|
||||
* 9: Other parameters <ARRAY> (Optional)
|
||||
* 10: Modifier function <CODE> (Optional)
|
||||
*
|
||||
* Return value:
|
||||
* Action <ARRAY>
|
||||
@ -27,7 +28,7 @@
|
||||
|
||||
EXPLODE_5_PVT(_this,_actionName,_displayName,_icon,_statement,_condition);
|
||||
|
||||
private ["_insertChildren","_customParams","_position","_distance","_params"];
|
||||
private ["_insertChildren","_customParams","_position","_distance","_params", "_modifierFunction"];
|
||||
|
||||
_insertChildren = if (count _this > 5) then {
|
||||
_this select 5
|
||||
@ -59,6 +60,12 @@ _params = if (count _this > 9) then {
|
||||
[false,false,false,false]
|
||||
};
|
||||
|
||||
_modifierFunction = if (count _this > 10) then {
|
||||
_this select 10
|
||||
} else {
|
||||
{}
|
||||
};
|
||||
|
||||
[
|
||||
_actionName,
|
||||
_displayName,
|
||||
@ -70,5 +77,6 @@ _params = if (count _this > 9) then {
|
||||
_customParams,
|
||||
_position,
|
||||
_distance,
|
||||
_params
|
||||
_params,
|
||||
_modifierFunction
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user