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

This subforum contains all the issues which we already resolved.
User avatar
Wiwiweb
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat May 08, 2021 2:36 am
Contact:

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

Post 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.
Attachments
artillery-transfer-test.zip
(1.13 MiB) Downloaded 82 times
User avatar
Wiwiweb
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat May 08, 2021 2:36 am
Contact:

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

Post 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 3590 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.
quyxkh
Smart Inserter
Smart Inserter
Posts: 1031
Joined: Sun May 08, 2016 9:01 am
Contact:

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

Post 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.
User avatar
Wiwiweb
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat May 08, 2021 2:36 am
Contact:

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

Post 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.
User avatar
Wiwiweb
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat May 08, 2021 2:36 am
Contact:

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

Post 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
Last edited by Wiwiweb on Mon Jan 30, 2023 12:23 am, edited 2 times in total.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14591
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

Thanks for the report. It's now fixed for the next release.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Resolved Problems and Bugs”