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