freghar / arma-additions

Other
4 stars 0 forks source link

Use Arma 3 Communication Menu for ACE-less gameplay #23

Open freghar opened 3 years ago

freghar commented 3 years ago
freghar commented 3 years ago

Don't use the submenu = argument, because it only allows for a static array-based submenu.

Instead, use a custom function in

class CfgCommunicationMenu {
    class a3aa_blabla {
        ...
        expression = "[_target,_pos] call a3aa_some_fnc_root_level_item";  //(_target=CursorTarget,_pos=CursorPos)
        ...
        enable = "1";
        removeAfterExpressionCall = 0;
    };
    ...

and have the function refresh the new info in a global variable, ie.

a3aa_some_var = [
    ["Some group 1", [0], "", -5, [["expression", format ["player assign group %1", _grp1] ]], "1", "1"],
    ["Some group 2", [0], "", -5, [["expression", format ["player assign group %1", _grp2] ]], "1", "1"]
];

and then manually call

showCommandingMenu "#USER:a3aa_some_var";

and (if you need to) wait for completion like

waituntil { commandingMenu != "#USER:a3aa_some_var" };

See also functions_f/Conversations/fn_kbMenu.sqf.

Remember to add the root menu item via

[player, "a3aa_some_fnc_root_level_item", nil, nil, ""] call BIS_fnc_addCommMenuItem;

TODO: Perhaps have a root "A3AA" item (because of maximum of 10 Supports menu items) that would have a function with some global array of sub-menu items, to which various arma-additions addons would add items (join group, etc.) whenever enabled.

freghar commented 2 years ago

Alternatively, avoid all this BS and just use journal diary entries and

<execute expression="sqf code here">blabla</execute>
OR
<executeClose expression="sqf code here">blabla</execute>

https://community.bistudio.com/wiki/createDiaryRecord