Page 1 of 1

[1.1.5] Copy-paste-tool reported as "blueprint" in on_player_setup_blueprint event.item

Posted: Mon Dec 07, 2020 2:09 am
by eradicator
The on_player_setup_blueprint event's "item" string is "blueprint" even when the copy-paste-tool was used.

Code: Select all

/c
script.on_event(defines.events.on_player_setup_blueprint, function(e)
  game.print(e.item)
  end)

Re: [1.1.5] Copy-paste-tool reported as "blueprint" in on_player_setup_blueprint event.item

Posted: Mon Dec 07, 2020 2:39 pm
by posila
I don't know if this is a bug. Copy-paste tool literally spawns a blueprint item in the cursor and that get's setup.

Re: [1.1.5] Copy-paste-tool reported as "blueprint" in on_player_setup_blueprint event.item

Posted: Mon Dec 07, 2020 2:56 pm
by eradicator
posila wrote: Mon Dec 07, 2020 2:39 pm I don't know if this is a bug. Copy-paste tool literally spawns a blueprint item in the cursor and that get's setup.
The api event doc states:
item :: string: The item used to select the area.
As the player.cursor_stack is already replaced by the blueprint during the event there's no way to distinguish between a normal blueprint select and a copy-paste-tool select otherwise.

Re: [1.1.5] Copy-paste-tool reported as "blueprint" in on_player_setup_blueprint event.item

Posted: Mon Dec 07, 2020 9:27 pm
by Rseding91
eradicator wrote: Mon Dec 07, 2020 2:56 pm
posila wrote: Mon Dec 07, 2020 2:39 pm I don't know if this is a bug. Copy-paste tool literally spawns a blueprint item in the cursor and that get's setup.
The api event doc states:
item :: string: The item used to select the area.
As the player.cursor_stack is already replaced by the blueprint during the event there's no way to distinguish between a normal blueprint select and a copy-paste-tool select otherwise.
I can update the Lua docs if wanted. But I don't consider it worth the time and annoying complexity to do anything around copy/cut-paste and blueprint re-assigning. It's a giant spaghetti mess that I don't want to stick more spaghetti code around. It's "what it is" and if it works for some peoples purposes that's great but after years of trying to make all the cases people have work It's just not worth it. Sorry.

Re: [1.1.5] Copy-paste-tool reported as "blueprint" in on_player_setup_blueprint event.item

Posted: Mon Dec 07, 2020 11:19 pm
by eradicator
Rseding91 wrote: Mon Dec 07, 2020 9:27 pm I can update the Lua docs if wanted.
Yes please. At the very least that should prevent other people from also getting a headache :D.

Just to be sure: This means that there currently is no straight-forward way to distinguish between a copy-paste made blueprint and a normal one right? So i'd have to do cursor_stack_changed heuristics, or maybe opened gui guessing.