Page 1 of 1

[1.1.74] LuaItemStack.transfer_stack only transfers 1 artillery shell from an artillery wagon to another

Posted: Sun Jan 29, 2023 2:46 am
by Wiwiweb
Reproduction:
  1. Create 2 artillery wagons (minimal save file included).
  2. Fill the first wagon with a bunch of artillery shells.
  3. Run this code:

    Code: Select all

    /c
    local a = game.surfaces.nauvis.find_entities_filtered{name="artillery-wagon"}
    local inv_a = a[1].get_inventory(defines.inventory.cargo_wagon) 
    local inv_b = a[2].get_inventory(defines.inventory.cargo_wagon)
    inv_b[1].transfer_stack(inv_a[1])
    
  4. Only 1 shell was transferred to the second wagon, where I would expect the whole stack to be transferred.

Re: [1.1.74] LuaItemStack.transfer_stack only transfers 1 artillery shell from an artillery wagon to another

Posted: Sun Jan 29, 2023 2:51 am
by Loewchen
1 is a whole stack though.

Re: [1.1.74] LuaItemStack.transfer_stack only transfers 1 artillery shell from an artillery wagon to another

Posted: Sun Jan 29, 2023 3:28 am
by Silari
Is the return true or false from the transfer call?

Re: [1.1.74] LuaItemStack.transfer_stack only transfers 1 artillery shell from an artillery wagon to another

Posted: Sun Jan 29, 2023 6:06 am
by Wiwiweb
Loewchen wrote: Sun Jan 29, 2023 2:51 am 1 is a whole stack though.
Screenshot 2023-01-28 220533.jpg
Screenshot 2023-01-28 220533.jpg (52.64 KiB) Viewed 3732 times
The artillery wagon contains 1 stack of 20 shells. Artillery wagons don't care about the stack size of shells.
Silari wrote: Sun Jan 29, 2023 3:28 am Is the return true or false from the transfer call?
True.

Re: [1.1.74] LuaItemStack.transfer_stack only transfers 1 artillery shell from an artillery wagon to another

Posted: Sun Jan 29, 2023 8:28 pm
by quyxkh

Code: Select all

/c game.print(game.item_prototypes['artillery-shell'].stack_size)
prints 1, and all other inventories stack them 1 per slot. Artillery wagons have some magic going on.

Re: [1.1.74] LuaItemStack.transfer_stack only transfers 1 artillery shell from an artillery wagon to another

Posted: Mon Jan 30, 2023 12:02 am
by Wiwiweb
It's a matter of definition. For me an item stack is a "LuaItemStack", and has nothing to do with the actual stack size of items. Most of the time, item stacks respect the stack size of items, but there are some exceptions (artillery wagons, the output slot of assembling machines, stacks over the limit after a prototype update that lowers the stack size...).

`transfer_stack` says "Transfers the given item stack into this item stack.". If this is meant to be "up to the maximum of the item's stack size" then I'd at least want confirmation of that before we go ahead and implement a special case for artillery wagon inventory transfer.

Re: [1.1.74] LuaItemStack.transfer_stack only transfers 1 artillery shell from an artillery wagon to another

Posted: Mon Jan 30, 2023 12:11 am
by Wiwiweb
I see this was moved to "Not a bug". I still think it's a bug, and I think the devs would agree too, but I don't want to escalate.
I spoke too soon :P

Re: [1.1.74] LuaItemStack.transfer_stack only transfers 1 artillery shell from an artillery wagon to another

Posted: Mon Jan 30, 2023 12:12 am
by Loewchen
Based on 59872 this seems indeed unintended.

Re: [1.1.74] LuaItemStack.transfer_stack only transfers 1 artillery shell from an artillery wagon to another

Posted: Tue Feb 07, 2023 6:26 pm
by Rseding91
Thanks for the report. It's now fixed for the next release.