Skip to content

Commit

Permalink
Add function to add curator actions (#5620)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror authored Oct 14, 2017
1 parent f6fd009 commit 65c5e6e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
1 change: 1 addition & 0 deletions addons/interact_menu/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

PREP(addActionToClass);
PREP(addActionToObject);
PREP(addActionToZeus);
PREP(addMainAction);
PREP(compileMenu);
PREP(compileMenuSelfAction);
Expand Down
45 changes: 45 additions & 0 deletions addons/interact_menu/functions/fnc_addActionToZeus.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Author: PabstMirror
* Insert an ACE action to zeus.
* Note: This function is NOT global.
*
* Arguments:
* 0: Parent path of the new action (e.g. ["ACE_ZeusActions"]) <ARRAY>
* 1: Action <ARRAY>
*
* Return Value:
* The entry full path, which can be used to add children entries <ARRAY>.
*
* Example:
* [["ACE_ZeusActions"], zeusAction] call ace_interact_menu_fnc_addActionToZeus;
*
* Public: Yes
*/
#include "script_component.hpp"

if (!params [["_parentPath", [], [[]]], ["_action", [], [[]], 11]]) exitWith {ERROR("Bad Params"); []};
if ((_parentPath param [0, ""]) != "ACE_ZeusActions") exitWith {ERROR_1("Bad path %1 - should have ACE_ZeusActions as base", _parentPath); []};
TRACE_2("addActionToZeus",_parentPath,_action);

private _currentPath = GVAR(ZeusActions);
private _pathValid = false;
{
private _targetParent = _x;
_pathValid = false;
{
_x params ["_xAction", "_xSubActions"];
TRACE_2("",_targetParent,_xAction);
if ((_xAction select 0) == _targetParent) exitWith {
_pathValid = true;
_currentPath = _xSubActions;
};
} forEach _currentPath;
} forEach _parentPath;

if (!_pathValid) exitWith {ERROR_1("Bad path %1", _parentPath); []};

TRACE_1("Adding Action",_currentPath);
_currentPath pushBack [_action, []];

// Return the full path
(_parentPath + [_action select 0])
26 changes: 24 additions & 2 deletions docs/wiki/framework/interactionMenu-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,19 @@ By default this function will not use inheritance, so actions will only be added
*/
```

### 2.4 Examples
### 2.4 fnc_addActionToZeus

`ace_interact_menu_fnc_addActionToZeus`

```cpp
/*
* Argument:
* 0: Parent path of the new action <ARRAY> (Example: `["ACE_ZeusActions"]`)
* 1: Action <ARRAY>
*/
```

### 2.5 Examples

External:

Expand Down Expand Up @@ -155,7 +167,17 @@ _action = ["CheckExtTank","Check External Tank","",{hint format ["Ext Tank: %1",
["Tank_F", 0, ["ACE_MainActions", "CheckFuel"], _action, true] call ace_interact_menu_fnc_addActionToClass;
```
### 2.5 Advanced Example
Zeus:
```cpp
_statement = {
playSound3D ["alarm.ogg", theBase]
};
_action = ["myMissionEvent1","Mission Event: Play Base Alarm","",_statement,{true}] call ace_interact_menu_fnc_createAction;
[["ACE_ZeusActions"], _action] call ace_interact_menu_fnc_addActionToZeus;
```

### 2.6 Advanced Example

This adds an interaction to a unit that allows passing items that the player is carrying.

Expand Down

0 comments on commit 65c5e6e

Please sign in to comment.