Page 1 of 1

[0.15.33] Item-with-inventory does not affect .opened

Posted: Mon Aug 14, 2017 5:25 am
by eradicator
game.player.opened is 'nil' even when an item-with-inventory is opened.

Reproduction:
1) get the item "/c game.player.insert('item-with-inventory')"
2) right click it to open the gui
3) try to get the type of the opened item e.g. "/c game.print(game.player.opened.type)"
4) ???
5) Error, "attempt to index field '.opened' (a nil value)

Re: [0.15.33] Item-with-inventory does not affect .opened

Posted: Mon Aug 14, 2017 5:29 am
by Rseding91
Thanks for the report.

http://lua-api.factorio.com/latest/LuaC ... rol.opened returns a variant of what the player has open. Not the type.

If you want to read just the type you do that through: http://lua-api.factorio.com/latest/LuaC ... d_gui_type

Re: [0.15.33] Item-with-inventory does not affect .opened

Posted: Mon Aug 14, 2017 5:42 am
by eradicator
Reading the type was just a proof of concept so to speak.
I actually need to access the inventory of the currently opend item-with-inventory, but as .opened == nil that is not possible. opened_gui_type returns defines.gui_type.item which is correct, but i don't see how that gets me any closer to the ItemStack or Inventory i need. I'm not sure what you mean by "a variant" so maybe i'm still misunderstanding something?

Edit:
To anyone who might find this post via search or otherwise: It is currently (0.15.33) not possible to get the ItemStack of the item-with-inventory a player has opened.