Basically what the title says.
Tried to do this and got an error:
The entity is a furnace, which, according to prototype wiki, is a crafting machine:
Allow furnaces' recipe to be reset using .set_recipe(nil)
Allow furnaces' recipe to be reset using .set_recipe(nil)
sent from nullium21's Smart Fridge
Re: Allow furnaces' recipe to be reset using .set_recipe(nil)
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.
Re: Allow furnaces' recipe to be reset using .set_recipe(nil)
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 amI 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.
sent from nullium21's Smart Fridge
Re: Allow furnaces' recipe to be reset using .set_recipe(nil)
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.
Re: Allow furnaces' recipe to be reset using .set_recipe(nil)
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.
Also, just noticed, the alt-view looks like the furnace keeps the recipe, but debug info says "Recipe: <none>". Is it a bug?
Re: Allow furnaces' recipe to be reset using .set_recipe(nil)
Clearing recipe on assembling machine is done through AssemblingMachine::reset which is also available only on AssemblingMachine. AssemblingMachine::setupForCrafting internally calls the AssemblingMachine::reset when it is given a RecipeID of "no recipe".
Furnaces have a "previous recipe id" which is used in certain cases (showing recipes on map, showing recipe in alt mode when furnace is not working). Value of the "previous recipe id" is accessible through LuaEntity::previous_recipe [R] which only works for Furnaces. It has no effects on furnace working state, its just a visualisation stuff due to how furnaces work: when a furnace finishes crafting, its recipe is automatically cleared and thats why the debug info says "Recipe: <none>" - debug stuff shows furnace's true current recipe without any layers of hiding them using previous recipe id.
Furnaces have a "previous recipe id" which is used in certain cases (showing recipes on map, showing recipe in alt mode when furnace is not working). Value of the "previous recipe id" is accessible through LuaEntity::previous_recipe [R] which only works for Furnaces. It has no effects on furnace working state, its just a visualisation stuff due to how furnaces work: when a furnace finishes crafting, its recipe is automatically cleared and thats why the debug info says "Recipe: <none>" - debug stuff shows furnace's true current recipe without any layers of hiding them using previous recipe id.