Tried to do this and got an error:

The entity is a furnace, which, according to prototype wiki, is a crafting machine:

Is there a reason for why it can't be used with other crafting machine types? Or, maybe, a workaround to clear the recipe?boskid wrote: Sun Sep 26, 2021 10:25 am I see there is a documentation error. As for 1.1.41, LuaEntity::set_recipe() is incorrectly documented saying it can be used with CraftingMachine while it should say it can only be used with AssemblingMachine. LuaEntity::get_recipe() is correct saying it works on CraftingMachine.
Yes of course there is a reason. LuaEntity::set_recipe() works by calling AssemblingMachine::setupForCrafting() on the c++ side which is only available on entities that can be casted to AssemblingMachine class. Furnaces have completly different recipe changing routine which looks at first item from source inventory or first fluid in the input fluid box.nullium21 wrote: Sun Sep 26, 2021 11:58 am Is there a reason for why it can't be used with other crafting machine types?
And what about clearing the recipe (.set_recipe(nil))?boskid wrote: LuaEntity::set_recipe() works by calling AssemblingMachine::setupForCrafting() on the c++ side which is only available on entities that can be casted to AssemblingMachine class. Furnaces have completly different recipe changing routine which looks at first item from source inventory or first fluid in the input fluid box.
Code: Select all
function respawn_furnace(reactor)
local surface = reactor.furnace.surface
local name = reactor.furnace.name
local position = reactor.furnace.position
local force = reactor.furnace.force
local quality = reactor.furnace.quality
local input = reactor.furnace.get_inventory(defines.inventory.furnace_source)
local output = reactor.furnace.get_output_inventory()
local input1 = nil
if input[1] and input[1].valid_for_read then
input1 = {name = input[1].name, count = input[1].count, quality = input[1].quality}
end
local output1 = nil
local output2 = nil
if output[1] and output[1].valid_for_read then
output1 = {name = output[1].name, count = output[1].count, quality = output[1].quality}
end
if output[2] and output[2].valid_for_read then
output2 = {name = output[2].name, count = output[2].count, quality = output[2].quality}
end
reactor.furnace.destroy()
reactor.furnace = surface.create_entity{name = name, position = position, force = force, quality = quality}
reactor.furnace.active = false
if input1 then
reactor.furnace.get_inventory(defines.inventory.furnace_source).insert(input1)
end
if output1 then
reactor.furnace.get_output_inventory().insert(output1)
end
if output2 then
reactor.furnace.get_output_inventory().insert(output2)
end
end
It's a furnace. Accepting every possible input at all times is its defining feature.ownlyme wrote: Mon Dec 23, 2024 4:25 pm and doesn't allow inserters to insert a different fuel cell (the latter is critical)