When "InventoryOpened" event handler triggers it only provides single container and omits cases where two containers were opened by same time - ground weapon holder and vehicle container nearby. I propose to extend "InventoryOpened" to provide both opened containers in cases where two were opened: [<unit>, <ground>, <crate>]. To retain backwards compatibility I suggest to include two only if there is actually two containers and return old format when there is just one container.
Description
Details
- Legacy ID
- 3905290776
- Severity
- None
- Resolution
- Fixed
- Reproducibility
- N/A
- Operating System
- Windows 7
- Category
- Scripting
- Open Editor, select Stratis
- Place player unit and add to Init line: player addEventHandler ["InventoryOpened", {systemChat str _this;}];
- Place any weapon crate nearby
- Start mission, stand right on the crate looking slightly above it so that there would be no "Inventory" action on it
- Press I to open Inventory and observe that event handler returned only new weapon holder while inventory screen has both Ground and Crate tabs active.
Additionally in case where two containers were opened "ContainerOpened" event handler should be called on both instead of one like it is right now.
Event Timeline
I fully agree with SaMatra, this feature is currently missing. It seems to be impossible to protect gear, by limiting the excess to it with the existing event handlers.
The first variant, extending the EH with an additional parameter, is the more comfortable solution, imho. Because it allows to easily handle everything in this single call. If the EH is called several times on the other hand, it might be required to synchronize the results.
Another event handler could also be helpful to detect when a player switches between the weapon holders in the inventory (e.g.: 'Ground' to 'Crate').
Suggestion:
InventorySwitched
- unit: Object - Object the event handler is assigned to
- containerOld: Object - The previous selected container or weaponholder
- containerNew: Object - The new selected container or weaponholder
As a workaround, all nearby containers could be retrieved with nearSupplies command. It is guaranteed that the missing container will be among them. How you then handle it is up to you.
1+
nearSupplies workaround can be a bit sloppy. Please do extend InventoryOpened EH to return all connected containers.
Still not solved, if you have body near crate and open body inventory, EH returns body and null object, while both body and crate are available in the inventory menu.