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

Post Reply
User avatar
Wiwiweb
Inserter
Inserter
Posts: 33
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 7 times

Post Reply

Return to “Assigned”