Page 1 of 1

[1.1.1] Changing input inventory and recipe of assembly machine in same tick doesn't update properly

Posted: Thu Nov 26, 2020 6:14 pm
by PFQNiet
I've noticed what appears to be a regression because as far as I'm aware it was working fine before the latest version.

Code: Select all

local machine = some_assembling_machine
local inventory = machine.get_inventory(defines.inventory.assembling_machine_input)
-- for this example the recipe takes 1 iron plate, and the machine contains 2 iron plates
inventory.remove{name="iron-plate",count=1}
local spill = machine.set_recipe(nil)
-- spill is expected to be the remaining 1 iron plate, but it is 2 iron plates instead
Basically it seems like changing the input inventory of the machine, then changing the recipe in the same tick, doesn't update properly.

I've worked around this issue by just using inventory.get_contents() before changing the recipe, but that workaround only works because I'm always setting the recipe to "nil". It wouldn't work if I were to set the recipe to something else that uses iron plates.

Re: [1.1.1] Changing input inventory and recipe of assembly machine in same tick doesn't update properly

Posted: Thu Nov 26, 2020 6:44 pm
by posila
Are you sure crafting is not in progress? Because craft cancel (i.e. by changing recipe) refunds ingredients.

Re: [1.1.1] Changing input inventory and recipe of assembly machine in same tick doesn't update properly

Posted: Thu Nov 26, 2020 7:22 pm
by PFQNiet
Oh that's possible. It's a "fake" crafting machine and since the GUI now shows a percentage value I decided to re-purpose that to show "percentage of ingredients submitted" instead and... now I feel stupid XD Of course, the game would treat that as a craft-in-progress and refund the items. Whoops!

My workaround is fine here, so this can be closed as not a bug. Thanks ^^

Re: [1.1.1] Changing input inventory and recipe of assembly machine in same tick doesn't update properly

Posted: Thu Nov 26, 2020 7:27 pm
by posila
You can disable refunding of ingredients by assembling-machine prototype property