diff --git a/api/lava_furnace_recipe.lua b/api/lava_furnace_recipe.lua index bc7d11f..3c56573 100644 --- a/api/lava_furnace_recipe.lua +++ b/api/lava_furnace_recipe.lua @@ -1,5 +1,5 @@ -local lava_furance_recipes = {} +local lava_furnace_recipes = {} local NORMAL_COOK_LAVA_USAGE_PER_SEC = 2 -- in millibuckets local NORMAL_COOK_REDUCTION_FACTOR = 2 local MIN_TIME = 0.5 @@ -23,8 +23,8 @@ function logistica.register_lava_furnace_recipe(def) end local useChance = (def.additive_use_chance ~= nil and logistica.clamp(def.additive_use_chance, 0, 100)) or 100 - lava_furance_recipes[def.input] = lava_furance_recipes[def.input] or {} - table.insert(lava_furance_recipes[def.input], { + lava_furnace_recipes[def.input] = lava_furnace_recipes[def.input] or {} + table.insert(lava_furnace_recipes[def.input], { input = def.input, input_count = def.input_count or 1, output = def.output, @@ -36,29 +36,32 @@ function logistica.register_lava_furnace_recipe(def) end function logistica.get_lava_furnace_recipes_for(itemName) - local presets = lava_furance_recipes[itemName] - if presets then return presets end + local presets = lava_furnace_recipes[itemName] - -- else, try to adopt the real one + -- also look for regular furnace recipe local output, decrOut = minetest.get_craft_result({ method = "cooking", width = 1, items = { ItemStack(itemName) } }) if output.time > 0 and decrOut.items[1]:is_empty() then local lavaTime = math.max(MIN_TIME, output.time / NORMAL_COOK_REDUCTION_FACTOR) - return {{ + local regularRecipe = { input_count = 1, output = output.item:to_string(), lava = lavaTime * NORMAL_COOK_LAVA_USAGE_PER_SEC, time = lavaTime - }} + } + + if presets then table.insert(presets, regularRecipe) + else presets = {regularRecipe} + end end - -- nothing found - return nil + -- returns nil for no matching recipes + return presets end -- returns a copy_pointed_thing of internal the internal recipes - for reference function logistica.get_lava_furnace_internal_recipes() - return table.copy(lava_furance_recipes) + return table.copy(lava_furnace_recipes) end \ No newline at end of file