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)
[0.15.33] Item-with-inventory does not affect .opened
- eradicator
- Smart Inserter

- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
[0.15.33] Item-with-inventory does not affect .opened
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: [0.15.33] Item-with-inventory does not affect .opened
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
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
If you want to get ahold of me I'm almost always on Discord.
- eradicator
- Smart Inserter

- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [0.15.33] Item-with-inventory does not affect .opened
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.
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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
