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

Bugs that are actually features.
Post Reply
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

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

Post 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.

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

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

Post by posila »

Are you sure crafting is not in progress? Because craft cancel (i.e. by changing recipe) refunds ingredients.

PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

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

Post 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 ^^

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

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

Post by posila »

You can disable refunding of ingredients by assembling-machine prototype property

Post Reply

Return to “Not a bug”