I figured out this:
Code: Select all
local stuff = inv.find_item_stack("item-name")
if stuff then
player.clean_cursor()
player.cursor_stack.set_stack(stuff)
player.remove_item(stuff)
end
Code: Select all
local stuff = inv.find_item_stack("item-name")
if stuff then
player.clean_cursor()
player.cursor_stack.set_stack(stuff)
player.remove_item(stuff)
end
That is what https://lua-api.factorio.com/latest/Lua ... swap_stack is for.bobingabout wrote: Thu Mar 14, 2019 1:40 pm moving an item stack from one inventory to another is something I'd like to see cleanly. AFAIK, currently, there's no easy way to move items with their own inventory, like power armor etc. I may be mistaken though, your code might do just that.
I tried swap_stack too, it still doesn't leave the "hand" placeholder in the player inventory if I do eitherBilka wrote: Thu Mar 14, 2019 2:11 pm That is what https://lua-api.factorio.com/latest/Lua ... swap_stack is for.
Code: Select all
local stuff = inv.find_item_stack("item-name")
if stuff then
player.clean_cursor()
player.cursor_stack.swap_stack(stuff)
end
Code: Select all
local stuff = inv.find_item_stack("item-name")
if stuff then
player.clean_cursor()
stuff.swap_stack(player.cursor_stack)
end