local recipes = data.raw.recipe local items = {} function return_item_prototype (item_name) local raw = data.raw local item_type_list = { "ammo", "armor", "gun", "item", "capsule", "repair-tool", "mining-tool", "item-with-entity-data", "rail-planner", "tool", "blueprint", "deconstruction-item", "blueprint-book", "selection-tool", "item-with-tags", "item-with-label", "item-with-inventory", "module"} for i, item_type in pairs (item_type_list) do if raw[item_type][item_name] then --log ('data.raw["'.. item_type ..'"]["'..item_name.. '"] was ok') return raw[item_type][item_name] end end return false end function pro_ingredients_or_results_iterator (ingredients_or_results) local must_be_deleted = false for number, tabl in pairs (ingredients_or_results) do -- data.raw.recipe["construction-roboport"].ingredients[1].name = "steel-plate" -- data.raw.recipe["construction-roboport"].ingredients[1].type = "item" -- data.raw.recipe["construction-roboport"].ingredients[1].amount = 40 -- data.raw.recipe["construction-roboport"].results[1].type = "item" -- data.raw.recipe["construction-roboport"].results[1].name = "construction-roboport" -- data.raw.recipe["construction-roboport"].results[1].amount = 1 if (tabl.type == 'item') then if not (return_item_prototype (tabl.name)) then must_be_deleted = true log ('Founded bad item! - ' .. tabl.name) end end end return must_be_deleted end function easy_results_iterator (recipe_handler, recipe_name) local must_be_deleted = false -- data.raw.recipe["stone-brick"].result = "stone-brick" if not (return_item_prototype (recipe_handler.result)) then must_be_deleted = true log ('Founded bad item! - ' .. recipe_handler.result) end return must_be_deleted end function check_recipe_handler (handler, recipe_name) local must_be_deleted = false if handler.ingredients then if (pro_ingredients_or_results_iterator (handler.ingredients)) then log ('Bad: '.. recipe_name) must_be_deleted = true end else log ('Easy recipes ingredients was not checked for '.. recipe_name) end if handler.results then if (pro_ingredients_or_results_iterator (handler.results)) then log ('Bad: '.. recipe_name) must_be_deleted = true end else if (easy_results_iterator (handler, recipe_name)) then log ('Easy recipes results was bad for '.. recipe_name) must_be_deleted = true end end return must_be_deleted end for recipe_name, recipe_prototype in pairs (recipes) do local must_be_deleted = false if recipe_prototype.normal and recipe_prototype.expensive then must_be_deleted = check_recipe_handler (recipe_prototype.normal, recipe_name) and check_recipe_handler (recipe_prototype.expensive, recipe_name) if must_be_deleted then log ('normal or expensive recipe ' .. recipe_name) end else must_be_deleted = check_recipe_handler (recipe_prototype, recipe_name) if must_be_deleted then log ('standard recipe ' .. recipe_name) end end if must_be_deleted then --delete recipe log ('The recipe was deleted: ' .. recipe_name) data.raw.recipe[recipe_name] = nil end end