Page 1 of 1

[Rseding91] [for 0.17] [0.16.37] [API] Inserting artillery shells is capped at 1

Posted: Thu Apr 26, 2018 11:14 am
by Aidiakapi
Likely because the stack size limit of artillery shells is 1, you cannot insert more than 1 into an artillery wagon using the modding API.

How to reproduce:
  1. Place some rail & artillery wagon.
  2. Hover over the wagon and run one or multiple of:

    Code: Select all

    /c game.player.selected.get_inventory(1).insert({name = 'artillery-shell', count = 10})
    /c game.player.selected.get_inventory(1)[1].set_stack({name = 'artillery-shell', count = 10})
    -- After inserting a single one:
    /c game.player.selected.get_inventory(1)[1].count = 10
Expected:
Multiple artillery shells to be inside the wagon, up to the limit a player can insert of 100.

Result:
At most 1 artillery shell is inserted.

Re: [16.37] [API] Inserting artillery shells is capped at 1

Posted: Thu Apr 26, 2018 11:18 am
by mrvn
iirc insert returns the amount inserted and you have to handle anything that remains yourself. Same if you have 30 coal in the inventory and insert 100. It will fill up the 30 to 50 (one stack) and return 20. Then you have to insert the remaining 80 into the next stack.

Re: [16.37] [API] Inserting artillery shells is capped at 1

Posted: Thu Apr 26, 2018 11:23 am
by Aidiakapi
mrvn wrote:iirc insert returns the amount inserted and you have to handle anything that remains yourself. Same if you have 30 coal in the inventory and insert 100. It will fill up the 30 to 50 (one stack) and return 20. Then you have to insert the remaining 80 into the next stack.
Sorry, but that's not what this post is about whatsoever. Artillery wagons only have a single LuaItemStack. The LuaInventory.insert function also takes care of the behavior you're describing.

Re: [0.16.37] [API] Inserting artillery shells is capped at 1

Posted: Fri May 11, 2018 3:18 am
by Rseding91
There are a few problems like this that need to be fixed - the same thing happens with assembling machines over stack limit.

At this point I don't want to mess with the logic in 0.16. I'll add it to the 0.17 to-do.