Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions api/lava_furnace_recipe.lua
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand All @@ -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