Armor repairing station


This mod gives you possibility to repair armor from vanilla or other mods.

Content
5 years ago
0.16
6
Armor

i Add generate recipe other armors

5 years ago

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

5 years ago

Thanks bro, it will be added in the next update :)

5 years ago
(updated 5 years ago)

// duplicate comment deleted

5 years ago

I found a bug. When you mine a plant, you get an "assembling-machine-3"

Fix in file: prototype/entity/armor_repairing_station.lua
entity.minable.result = namesDefinitions.armorRepairStation

5 years ago

Oh, thanks again, it also will be added soon :)

5 years ago

v0.2.0 released with your generation and bugfix

5 years ago

Thread locked because suggestion has been implemented

This thread has been locked.