Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item context menu is not updated upon interaction #1432

Closed
BaerMitUmlaut opened this issue Mar 7, 2021 · 5 comments · Fixed by #1455
Closed

Item context menu is not updated upon interaction #1432

BaerMitUmlaut opened this issue Mar 7, 2021 · 5 comments · Fixed by #1455
Labels

Comments

@BaerMitUmlaut
Copy link
Contributor

BaerMitUmlaut commented Mar 7, 2021

Mods (complete and add to the following information):

  • Arma 3: 2.02
  • CBA: 3.15.2

Description:
The item context menu is never updated, even when an action is executed. This can cause conflicts between mods, since one mod can add an action that leaves the menu open, but should disable or enable a different action. In my opinion, this is an oversight and can cause unexpected behaviours.

Steps to reproduce:

  • Execute the following:
    [
        "acc_pointer_IR", "POINTER", "CONSUME", [], "", {true}, {true}, true
    ] call CBA_fnc_addItemContextMenuOption;
  • Use the action

Expected behavior:
The action should disappear.

Additional context:
The easiest and most solid solution would probably be updating the menu through an inventory player event handler.

@commy2
Copy link
Contributor

commy2 commented Mar 8, 2021

What do you mean by "is never updated"? Does the old action appear on the next item on the list or?

@BaerMitUmlaut
Copy link
Contributor Author

The actions remain the same, regardless what happens with the item. If the item gets replaced or removed completely, the context menu stays open with the same options, which may not be valid anymore.

@commy2
Copy link
Contributor

commy2 commented May 21, 2021

This is a user error. The correct way to make a consumable item is to make the statement return false (or anything else that is not true including nil).

[ 
    "acc_pointer_IR", "POINTER", "CONSUME", [], "", {true}, {nil}, true 
] call CBA_fnc_addItemContextMenuOption;

@commy2
Copy link
Contributor

commy2 commented May 21, 2021

Additionally, the action is already not executed multiple times, so even if this bug is present, no exploit can come from it:

[
    "30Rnd_65x39_caseless_mag", "CONTAINER", "CONSUME", [], "", {true}, {
    systemChat str ["consumed", diag_frameno];
    true
}, true] call CBA_fnc_addItemContextMenuOption;

@commy2
Copy link
Contributor

commy2 commented May 21, 2021

The correct way to code a consuming item with a menu that sticks around is:

[
    "30Rnd_65x39_caseless_mag", "CONTAINER", "CONSUME", [], "", {true}, {
    params ["_unit", "_container", "_item"];

    systemChat format ["%1 consumed %2 from %3 - frame: %4",
        name _unit, _item, typeOf _container, diag_frameno
    ];

    _item in magazineCargo _container
}, true] call CBA_fnc_addItemContextMenuOption;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants