on_gui_opened Event
Posted: Fri Oct 29, 2021 4:50 pm
I am listening to the on_gui_opened event in my control.lua and have some behaviour I do not understand. Some sample code below:
If I right click some power armor in my main inventory then the event.item is a 'LuaItemStack' and event.gui.type is '5' (defines.gui_type.item). If I right click some power armor in a chest then event.item is 'nil' and event.gui.type is '5' (defines.gui_type.item). Both times the equipment grid is displayed as normal.
What I don't understand is where the armor is placed seems to make a difference to the event.item value. Isn't a chest just a LuaInventory (and the power armor a LuaItemStack), in the same way the player main inventory is?
This has come about as I would like to know which armor an equipment grid has been opened for.
Thanks in advance!
Code: Select all
script.on_event(defines.events.on_gui_opened, function(event)
game.print("called on_gui_opened")
game.print(event.item)
game.print(event.gui_type)
end)
What I don't understand is where the armor is placed seems to make a difference to the event.item value. Isn't a chest just a LuaInventory (and the power armor a LuaItemStack), in the same way the player main inventory is?
This has come about as I would like to know which armor an equipment grid has been opened for.
Thanks in advance!