Hello!
Please add auto generate recipes for other armors
See:
File: util/recipe.lua
local recipeUtils = {}
function math.sign(v)
return (v >= 0 and 1) or -1
end
function math.round(v, bracket)
bracket = bracket or 1
return math.floor(v/bracket + math.sign(v) * 0.5) * bracket
end
recipeUtils.generateRepairRecipe = function(itemPrototype, ingredientsx)
local recipe = {
type = "recipe",
name = itemPrototype.name .. "-repairing",
localised_name = {"recipe-name.armor-repairing", {"item-name." .. itemPrototype.name}},
category = "armor-repairing",
ingredients = {
{
type = "item",
name = itemPrototype.name,
amount = 1
}
},
result = itemPrototype.name
}
for _, ingredient in pairs(ingredientsx) do
if not data.raw["armor"][ing.name] then
local ing = {
type = ingredient.type or "item",
name = ingredient.name or ingredient[1],
amount = ingredient.amount or ingredient[2]
}
if ing.amount ~= nil and ing.amount > 1 then
ing.amount = math.round(ing.amount / 2)
end
table.insert(recipe.ingredients, ing)
end
end
return recipe
end
return recipeUtils
File: data-final-fixes.lua
local recipe = require("util.recipe")
for _, item in pairs(data.raw["armor"]) do
if not data.raw["recipe"][item.name .. "-repairing"] then
local r = data.raw["recipe"][item.name]
if r ~= nil then
data:extend({
recipe.generateRepairRecipe(item, r.ingredients)
})
end
end
end
Localization: Use template string
[recipe-name]
armor-repairing=Repair 1