I don't even alter name at any point.
I am pretty sure there is no infinite loop here, but without debug messages, I can't be certain.
Code: Select all
function process(recipe)
if not recipe.processed then
local energy = 0.5
if recipe.ingredients then
for i, ingredient in pairs(recipe.ingredients) do
--process(ingredient) -- This here
energy = energy + 0.3
if ingredient[2] then
energy = energy + 0.2*ingredient[2]
else
end
if recipe.energyRequired then
energy = energy + 0.2*recipe.energy_required
end
if recipe.result_count then
energy = energy * recipe.result_count
end
end
else
end
--result = "night-vision-equipment"
recipe.energy_required = energy
recipe.processed = true
end
end
for i, recipe in pairs (data.raw["recipe"]) do
if (recipe.category == nil) or (recipe.category == "advanced-crafting") then
process(recipe)
end
end
for i, recipe in pairs (data.raw["recipe"]) do
recipe.processed = nil
end