function update_ingredients (recipe_name, recipe, difficulty) -- 'ingredients' local ingredients = recipe.ingredients local difficulty = difficulty or "" for i, num_ing in pairs (ingredients) do if not (num_ing.type) then log ("Msg_1: " .. recipe_name .. " " .. num_ing[1] .. " " .. difficulty .. " has no type!") num_ing.type = "item" end if num_ing[1] then num_ing.name = num_ing[1] num_ing.amount = num_ing[2] num_ing[1] = nil num_ing[2] = nil log ("Msg_2: " .. recipe_name .. " " .. difficulty .. " was rewritten " .. serpent.block(num_ing, {comment = false})) else log ("Msg_3: " .. recipe_name .. " " .. difficulty .. " was ok - " .. num_ing.type .. " - " .. num_ing.name) end end end function update_results (recipe_name, recipe, difficulty) -- 'results' local difficulty = difficulty or "" if recipe.result and recipe.results then log ("Too much results defided! It was " .. recipe_name) end if recipe.result then local result = {} result["type"] = "item" result["name"] = recipe.result result["amount"] = recipe.result_count or 1 local results = recipe.results or {} results[#results + 1] = result recipe.results = results recipe.result = nil recipe.result_count = nil end for i, v in pairs (recipe.results) do if not (v.type) then log ("By " .. recipe_name .. " - " .. v.name .. " was no type! Type added.") v.type = "item" end end end -- 'start' local recipes = data.raw.recipe for recipe_name, recipe in pairs (recipes) do if recipe.normal then update_ingredients (recipe_name, recipe.normal, "normal") update_results (recipe_name, recipe.normal, "normal") update_ingredients (recipe_name, recipe.expensive, "expensive") update_results (recipe_name, recipe.expensive, "expensive") else update_ingredients (recipe_name, recipe) update_results (recipe_name, recipe) end end -- 'end'