Page 1 of 1

[0.16.16] LuaPlayer::blueprint_to_setup invalid

Posted: Tue Jan 16, 2018 7:37 pm
by Therax
When an area is selected with a blank blueprint while holding SHIFT to suppress display of the editing window, during the on_player_setup_blueprint event LuaPlayer::blueprint_to_setup is an invalid ItemStack.

The on_player_configured_blueprint event is also never fired, in sum giving mods no opportunity to adjust the contents of a blueprint created in this way.

Selecting without holding SHIFT works as expected.

Steps to repro:
1) setup script handler:

Code: Select all

/c script.on_event(defines.events.on_player_setup_blueprint, function(e) game.print(serpent.line(game.players[e.player_index].blueprint_to_setup.valid_for_read)) end)
2) Drag-select entities with an empty blueprint while holding SHIFT.
3) Script displays "false", expected "true," with the ItemStack holding the blueprinted entities.

Re: [0.16.16] LuaPlayer::blueprint_to_setup invalid

Posted: Tue Jan 16, 2018 9:35 pm
by Rseding91
Thanks for the report however that's working as intended. There is no "setup" that happens when you hold shift - holding shift bypasses that system completely (as it's intended to do). In that case the blueprint you want is in the players cursor.

Re: [0.16.16] LuaPlayer::blueprint_to_setup invalid

Posted: Tue Jan 16, 2018 9:48 pm
by Therax
Got it, and confirmed that when holding SHIFT, game.players[event.player_index].cursor_stack.get_blueprint_entities() is accessible.

Perhaps a documentation update is in order? When SHIFT is not held, on_player_setup_blueprint is raised before the blueprint in the cursor is actually setup, but during alt-select it's raised after the cursor's blueprint is setup. It's a little confusing. :)