[Genhis] [1.1.70] LuaItemStack.swap_stack does not keep the temporary nature of items

Post Reply
User avatar
Wiwiweb
Inserter
Inserter
Posts: 39
Joined: Sat May 08, 2021 2:36 am
Contact:

[Genhis] [1.1.70] LuaItemStack.swap_stack does not keep the temporary nature of items

Post by Wiwiweb »

As discussed on discord with Klonan:
https://discord.com/channels/1396775903 ... 1213481020
Reproduction:
* Get a save file with 2 characters (save file included)
* Get a deconstruction planner in hand (alt+D). Dismiss it (Q). It disappears and does not go to the inventory, as expected.
* Get a deconstruction planner in hand again.
* Swap character and swap cursor stack using this:

Code: Select all

/c 
local old_char = game.surfaces.nauvis.find_entities_filtered{name = "character", force = "player", limit = 1, position = {-5.5,0.5}, radius = 2}[1]
local new_char = game.surfaces.nauvis.find_entities_filtered{name = "character", force = "player", limit = 1, position = {7.5,0.5}, radius = 2}[1]
game.player.set_controller{type=defines.controllers.character, character=new_char}
new_char.cursor_stack.swap_stack(old_char.cursor_stack)
* You are now the controlling the other character, but you still have the deconstruction planner in hand.
* Dismiss it (Q). The empty planner goes to inventory instead of disappearing.

This is an issue for the Jetpack mod, where it can cause players to end up with lots of empty planners in their inventories.
Attachments
swap_stack_bug.zip
(1.07 MiB) Downloaded 13 times

Genhis
Factorio Staff
Factorio Staff
Posts: 78
Joined: Wed Dec 24, 2014 8:19 am
Contact:

Re: [Genhis] [1.1.70] LuaItemStack.swap_stack does not keep the temporary nature of items

Post by Genhis »

This is not a bug. LuaItemStack doesn't know it is supposed to be temporary. I am moving it to modding interface requests.

For the next release, I added LuaPlayer::cursor_stack_temporary (read/write boolean) which you can use to mark cursor stack as temporary. It works for blueprints, blueprint books, deconstruction planners and upgrade planners. If a player holds a different type in the cursor, write operation is silently ignored.

User avatar
Wiwiweb
Inserter
Inserter
Posts: 39
Joined: Sat May 08, 2021 2:36 am
Contact:

Re: [Genhis] [1.1.70] LuaItemStack.swap_stack does not keep the temporary nature of items

Post by Wiwiweb »

That's great! Thanks!

Post Reply

Return to “Implemented mod requests”