Expected:
When opening or closing a blueprint or blueprint book contained within an outer blueprint book, the on_gui_opened / on_gui_closed events should be fired, and event.item should be a LuaItemStack pointing to the contained blueprint or blueprint book, as accessible via the expression "blueprint_book.get_inventory(defines.inventory.item_main)[ i ]" with the appropriate index.
Actual:
The on_gui_opened / on_gui_closed events fire with event.gui_type equal to defines.gui_type.item, but event.item is always nil.
[Rseding91] [1.1.53] item field not populated during on_gui_opened/on_gui_closed for blueprint book contents
[Rseding91] [1.1.53] item field not populated during on_gui_opened/on_gui_closed for blueprint book contents
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Re: [1.1.53] item field not populated during on_gui_opened/on_gui_closed for blueprint book contents
Thanks for the report however, it is there. Are you referring to opening blueprint books in the library? In that case, the library blueprints aren't actual items so there is no item to reference for the Lua API.
If you want to get ahold of me I'm almost always on Discord.
Re: [1.1.53] item field not populated during on_gui_opened/on_gui_closed for blueprint book contents
Just to make sure we're clear, opening a blueprint book in character inventory is fine.
Opening a blueprint book nested *inside* another blueprint book is not.
Opening a blueprint inside a blueprint book is not.
Detailed repro:
1. Start a new freeplay game.
2. Place down the initial stone furnace.
3. Create a blueprint book, add it to the character inventory.
4. Create a blueprint of the stone furnace, and add it to the blueprint book in slot 1.
5. Close all GUIs.
6. In the console:
"/c script.on_event(defines.events.on_gui_opened, function (e) log(serpent.line(e)) end)"
"/c script.on_event(defines.events.on_gui_closed, function (e) log(serpent.line(e)) end)"
7. Open the character inventory. Open the blueprint book with RMB. Right-click the blueprint to open its GUI.
Observe the following events in the log:
1st event is opening the controller GUI.
2nd event is opening the blueprint book. This event carries an "item" field.
3rd event is opening the blueprint. Note it has no "item" field.
8. Close the blueprint GUI and restore the blueprint book GUI by clicking the X. Repeat for the blueprint book, and the character inventory.
9. New events in the log:
Again, note the first event (closing the blueprint GUI) has no "item" field.
0.001 2022-02-17 15:13:29; Factorio 1.1.53 (build 59373, win64, steam)
No mods enabled:
1.377 Loading mod core 0.0.0 (data.lua)
1.436 Loading mod base 1.1.53 (data.lua)
1.703 Loading mod base 1.1.53 (data-updates.lua)
1.802 Checksum for core: 1625176034
1.802 Checksum of base: 98178652
2.017 Prototype list checksum: 3034860339
Opening a blueprint book nested *inside* another blueprint book is not.
Opening a blueprint inside a blueprint book is not.
Detailed repro:
1. Start a new freeplay game.
2. Place down the initial stone furnace.
3. Create a blueprint book, add it to the character inventory.
4. Create a blueprint of the stone furnace, and add it to the blueprint book in slot 1.
5. Close all GUIs.
6. In the console:
"/c script.on_event(defines.events.on_gui_opened, function (e) log(serpent.line(e)) end)"
"/c script.on_event(defines.events.on_gui_closed, function (e) log(serpent.line(e)) end)"
7. Open the character inventory. Open the blueprint book with RMB. Right-click the blueprint to open its GUI.
Observe the following events in the log:
Code: Select all
171.835 Script script.on_event(defines.events.on_gui_opened, function (e) log(serpent.line(e)) end):1: {gui_type = 3, name = 86, player_index = 1, tick = 9543}
174.454 Script script.on_event(defines.events.on_gui_opened, function (e) log(serpent.line(e)) end):1: {gui_type = 5, item = {__self = "userdata"}, name = 86, player_index = 1, tick = 9700}
175.954 Script script.on_event(defines.events.on_gui_opened, function (e) log(serpent.line(e)) end):1: {gui_type = 5, name = 86, player_index = 1, tick = 9790}
2nd event is opening the blueprint book. This event carries an "item" field.
3rd event is opening the blueprint. Note it has no "item" field.
8. Close the blueprint GUI and restore the blueprint book GUI by clicking the X. Repeat for the blueprint book, and the character inventory.
9. New events in the log:
Code: Select all
247.537 Script script.on_event(defines.events.on_gui_closed, function (e) log(serpent.line(e)) end):1: {gui_type = 5, name = 87, player_index = 1, tick = 14084}
278.100 Script script.on_event(defines.events.on_gui_closed, function (e) log(serpent.line(e)) end):1: {gui_type = 5, item = {__self = "userdata"}, name = 87, player_index = 1, tick = 15918}
279.718 Script script.on_event(defines.events.on_gui_closed, function (e) log(serpent.line(e)) end):1: {gui_type = 3, name = 87, player_index = 1, tick = 16015}
0.001 2022-02-17 15:13:29; Factorio 1.1.53 (build 59373, win64, steam)
No mods enabled:
1.377 Loading mod core 0.0.0 (data.lua)
1.436 Loading mod base 1.1.53 (data.lua)
1.703 Loading mod base 1.1.53 (data-updates.lua)
1.802 Checksum for core: 1625176034
1.802 Checksum of base: 98178652
2.017 Prototype list checksum: 3034860339
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Re: [Rseding91] [1.1.53] item field not populated during on_gui_opened/on_gui_closed for blueprint book contents
I too have come across this bug from a recent report. The same behaviour is still being observed in 1.1.74 where closing a blueprint in a blueprint book fires on_gui_closed with defines.gui_type.item as gui_type but no item was returned.
Re: [Rseding91] [1.1.53] item field not populated during on_gui_opened/on_gui_closed for blueprint book contents
This is now fixed for 1.2.
If you want to get ahold of me I'm almost always on Discord.