Avoid unnecessary registration

This commit is contained in:
AFCMS 2021-03-29 21:39:04 +02:00
parent 9990db92b4
commit 31027aca2e
1 changed files with 68 additions and 64 deletions

View File

@ -186,66 +186,71 @@ for _,first_color in ipairs(colors) do
}) })
itemcount = itemcount + 4 itemcount = itemcount + 4
for _,second_color in ipairs(colors) do for _,second_color in ipairs(colors) do
minetest.register_tool("mcl_armor:helmet_leather_"..first_color[1].."_"..second_color[1], { if minetest.registered_tools["mcl_armor:helmet_leather_"..second_color[1].."_"..first_color[1]] then
description = S("Leather Cap "..first_color[2].." "..second_color[2]), minetest.register_alias("mcl_armor:helmet_leather_"..first_color[1].."_"..second_color[1], "mcl_armor:helmet_leather_"..second_color[1].."_"..first_color[1]) --Avoid unnecessary registration
_doc_items_longdesc = longdesc, else
_doc_items_usagehelp = usage, minetest.register_tool("mcl_armor:helmet_leather_"..first_color[1].."_"..second_color[1], {
inventory_image = "mcl_armor_inv_helmet_leather.png", description = S("Leather Cap "..first_color[2].." "..second_color[2]),
texture = "mcl_armor_helmet_leather.png", _doc_items_longdesc = longdesc,
groups = {armor_head=1, mcl_armor_points=1, mcl_armor_uses=56, enchantability=15}, _doc_items_usagehelp = usage,
_repair_material = "mcl_mobitems:leather", inventory_image = "mcl_armor_inv_helmet_leather.png",
sounds = { texture = "mcl_armor_helmet_leather.png",
_mcl_armor_equip = "mcl_armor_equip_leather", groups = {armor_head=1, mcl_armor_points=1, mcl_armor_uses=56, enchantability=15},
_mcl_armor_unequip = "mcl_armor_unequip_leather", _repair_material = "mcl_mobitems:leather",
}, sounds = {
on_place = get_on_armor_leather_use(itemname, "mcl_armor:helmet_leather"), _mcl_armor_equip = "mcl_armor_equip_leather",
on_secondary_use = get_on_armor_leather_use(itemname, "mcl_armor:helmet_leather"), _mcl_armor_unequip = "mcl_armor_unequip_leather",
}) },
minetest.register_tool("mcl_armor:chestplate_leather_"..first_color[1].."_"..second_color[1], { on_place = get_on_armor_leather_use(itemname, "mcl_armor:helmet_leather"),
description = S("Leather Tunic "..first_color[2].." "..second_color[2]), on_secondary_use = get_on_armor_leather_use(itemname, "mcl_armor:helmet_leather"),
_doc_items_longdesc = longdesc, })
_doc_items_usagehelp = usage, minetest.register_tool("mcl_armor:chestplate_leather_"..first_color[1].."_"..second_color[1], {
inventory_image = "mcl_armor_inv_chestplate_leather.png", description = S("Leather Tunic "..first_color[2].." "..second_color[2]),
texture = "mcl_armor_chestplate_leather.png", _doc_items_longdesc = longdesc,
groups = {armor_torso=1, mcl_armor_points=3, mcl_armor_uses=81, enchantability=15 }, _doc_items_usagehelp = usage,
_repair_material = "mcl_mobitems:leather", inventory_image = "mcl_armor_inv_chestplate_leather.png",
sounds = { texture = "mcl_armor_chestplate_leather.png",
_mcl_armor_equip = "mcl_armor_equip_leather", groups = {armor_torso=1, mcl_armor_points=3, mcl_armor_uses=81, enchantability=15 },
_mcl_armor_unequip = "mcl_armor_unequip_leather", _repair_material = "mcl_mobitems:leather",
}, sounds = {
on_place = get_on_armor_leather_use(itemname, "mcl_armor:chestplate_leather"), _mcl_armor_equip = "mcl_armor_equip_leather",
on_secondary_use = get_on_armor_leather_use(itemname, "mcl_armor:chestplate_leather"), _mcl_armor_unequip = "mcl_armor_unequip_leather",
}) },
minetest.register_tool("mcl_armor:leggings_leather_"..first_color[1].."_"..second_color[1], { on_place = get_on_armor_leather_use(itemname, "mcl_armor:chestplate_leather"),
description = S("Leather Pants "..first_color[2].." "..second_color[2]), on_secondary_use = get_on_armor_leather_use(itemname, "mcl_armor:chestplate_leather"),
_doc_items_longdesc = longdesc, })
_doc_items_usagehelp = usage, minetest.register_tool("mcl_armor:leggings_leather_"..first_color[1].."_"..second_color[1], {
inventory_image = "mcl_armor_inv_leggings_leather.png", description = S("Leather Pants "..first_color[2].." "..second_color[2]),
texture = "mcl_armor_leggings_leather.png", _doc_items_longdesc = longdesc,
groups = {armor_legs=1, mcl_armor_points=2, mcl_armor_uses=76, enchantability=15 }, _doc_items_usagehelp = usage,
_repair_material = "mcl_mobitems:leather", inventory_image = "mcl_armor_inv_leggings_leather.png",
sounds = { texture = "mcl_armor_leggings_leather.png",
_mcl_armor_equip = "mcl_armor_equip_leather", groups = {armor_legs=1, mcl_armor_points=2, mcl_armor_uses=76, enchantability=15 },
_mcl_armor_unequip = "mcl_armor_unequip_leather", _repair_material = "mcl_mobitems:leather",
}, sounds = {
on_place = get_on_armor_leather_use(itemname, "mcl_armor:leggings_leather"), _mcl_armor_equip = "mcl_armor_equip_leather",
on_secondary_use = get_on_armor_leather_use(itemname, "mcl_armor:leggings_leather"), _mcl_armor_unequip = "mcl_armor_unequip_leather",
}) },
minetest.register_tool("mcl_armor:boots_leather_"..first_color[1].."_"..second_color[1], { on_place = get_on_armor_leather_use(itemname, "mcl_armor:leggings_leather"),
description = S("Leather Boots "..first_color[2].." "..second_color[2]), on_secondary_use = get_on_armor_leather_use(itemname, "mcl_armor:leggings_leather"),
_doc_items_longdesc = longdesc, })
_doc_items_usagehelp = usage, minetest.register_tool("mcl_armor:boots_leather_"..first_color[1].."_"..second_color[1], {
inventory_image = "mcl_armor_inv_boots_leather.png", description = S("Leather Boots "..first_color[2].." "..second_color[2]),
texture = "mcl_armor_leggins_leather.png", _doc_items_longdesc = longdesc,
groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=66, enchantability=15 }, _doc_items_usagehelp = usage,
_repair_material = "mcl_mobitems:leather", inventory_image = "mcl_armor_inv_boots_leather.png",
sounds = { texture = "mcl_armor_leggins_leather.png",
_mcl_armor_equip = "mcl_armor_equip_leather", groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=66, enchantability=15 },
_mcl_armor_unequip = "mcl_armor_unequip_leather", _repair_material = "mcl_mobitems:leather",
}, sounds = {
on_place = get_on_armor_leather_use(itemname, "mcl_armor:boots_leather"), _mcl_armor_equip = "mcl_armor_equip_leather",
on_secondary_use = get_on_armor_leather_use(itemname, "mcl_armor:boots_leather"), _mcl_armor_unequip = "mcl_armor_unequip_leather",
}) },
on_place = get_on_armor_leather_use(itemname, "mcl_armor:boots_leather"),
on_secondary_use = get_on_armor_leather_use(itemname, "mcl_armor:boots_leather"),
})
itemcount = itemcount + 4
end
minetest.register_craft({ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = "mcl_armor:helmet_leather_"..first_color[1].."_"..second_color[1], output = "mcl_armor:helmet_leather_"..first_color[1].."_"..second_color[1],
@ -266,12 +271,11 @@ for _,first_color in ipairs(colors) do
output = "mcl_armor:boots_leather_"..first_color[1].."_"..second_color[1], output = "mcl_armor:boots_leather_"..first_color[1].."_"..second_color[1],
recipe = {"mcl_armor:boots_leather_"..first_color[1], second_color[3]}, recipe = {"mcl_armor:boots_leather_"..first_color[1], second_color[3]},
}) })
itemcount = itemcount + 4
end end
end end
--minetest.register_on_joinplayer(function() minetest.register_on_joinplayer(function()
-- minetest.chat_send_all(itemcount) minetest.chat_send_all(itemcount)
--end) end)
minetest.log("info", "[mcl_armor] "..itemcount.." leather armor pieces have been registered") minetest.log("info", "[mcl_armor] "..itemcount.." leather armor pieces have been registered")