From b17d8ea55a5c2ad0d56787fdbb9fa18055bd334d Mon Sep 17 00:00:00 2001 From: stujones11 Date: Thu, 19 Feb 2015 18:53:31 +0000 Subject: [PATCH] Allow individual armor materials to be disabled via armor.conf --- .gitignore | 1 + 3d_armor/armor.conf.example | 12 ++ 3d_armor/armor.lua | 13 ++ 3d_armor/init.lua | 356 ++++++++++++++++-------------------- 4 files changed, 184 insertions(+), 198 deletions(-) diff --git a/.gitignore b/.gitignore index a57dbc9..6e4e459 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ *bak* tags *.vim +armor.conf diff --git a/3d_armor/armor.conf.example b/3d_armor/armor.conf.example index aa01084..0270af9 100644 --- a/3d_armor/armor.conf.example +++ b/3d_armor/armor.conf.example @@ -1,5 +1,17 @@ -- Armor Configuration (defaults) +-- You can remove any unwanted armor materials from this table. +-- Note that existing armor that is removed will show up as an unknown item. +ARMOR_MATERIALS = { + wood = "default:wood", + cactus = "default:cactus", + steel = "default:steel_ingot", + bronze = "default:bronze_ingot", + diamond = "default:diamond", + gold = "default:gold_ingot", + mithril = "moreores:mithril_ingot", +} + -- Increase this if you get initialization glitches when a player first joins. ARMOR_INIT_DELAY = 1 diff --git a/3d_armor/armor.lua b/3d_armor/armor.lua index 6f2bd6e..becb139 100644 --- a/3d_armor/armor.lua +++ b/3d_armor/armor.lua @@ -6,6 +6,15 @@ ARMOR_DROP = minetest.get_modpath("bones") ~= nil ARMOR_DESTROY = false ARMOR_LEVEL_MULTIPLIER = 1 ARMOR_HEAL_MULTIPLIER = 1 +ARMOR_MATERIALS = { + wood = "default:wood", + cactus = "default:cactus", + steel = "default:steel_ingot", + bronze = "default:bronze_ingot", + diamond = "default:diamond", + gold = "default:gold_ingot", + mithril = "moreores:mithril_ingot", +} local skin_mod = nil local inv_mod = nil @@ -24,6 +33,10 @@ if input then input:close() input = nil end +if not minetest.get_modpath("moreores") then + ARMOR_MATERIALS.mithril = nil +end + local time = 0 diff --git a/3d_armor/init.lua b/3d_armor/init.lua index fa825f2..9d5d986 100644 --- a/3d_armor/init.lua +++ b/3d_armor/init.lua @@ -2,212 +2,187 @@ ARMOR_MOD_NAME = minetest.get_current_modname() dofile(minetest.get_modpath(ARMOR_MOD_NAME).."/armor.lua") dofile(minetest.get_modpath(ARMOR_MOD_NAME).."/admin.lua") -local use_moreores = minetest.get_modpath("moreores") +if ARMOR_MATERIALS.wood then + minetest.register_tool("3d_armor:helmet_wood", { + description = "Wood Helmet", + inventory_image = "3d_armor_inv_helmet_wood.png", + groups = {armor_head=5, armor_heal=0, armor_use=2000}, + wear = 0, + }) + minetest.register_tool("3d_armor:chestplate_wood", { + description = "Wood Chestplate", + inventory_image = "3d_armor_inv_chestplate_wood.png", + groups = {armor_torso=10, armor_heal=0, armor_use=2000}, + wear = 0, + }) + minetest.register_tool("3d_armor:leggings_wood", { + description = "Wood Leggings", + inventory_image = "3d_armor_inv_leggings_wood.png", + groups = {armor_legs=5, armor_heal=0, armor_use=2000}, + wear = 0, + }) + minetest.register_tool("3d_armor:boots_wood", { + description = "Wood Boots", + inventory_image = "3d_armor_inv_boots_wood.png", + groups = {armor_feet=5, armor_heal=0, armor_use=2000}, + wear = 0, + }) +end --- Regisiter Head Armor +if ARMOR_MATERIALS.cactus then + minetest.register_tool("3d_armor:helmet_cactus", { + description = "Cactuc Helmet", + inventory_image = "3d_armor_inv_helmet_cactus.png", + groups = {armor_head=5, armor_heal=0, armor_use=1000}, + wear = 0, + }) + minetest.register_tool("3d_armor:chestplate_cactus", { + description = "Cactus Chestplate", + inventory_image = "3d_armor_inv_chestplate_cactus.png", + groups = {armor_torso=10, armor_heal=0, armor_use=1000}, + wear = 0, + }) + minetest.register_tool("3d_armor:leggings_cactus", { + description = "Cactus Leggings", + inventory_image = "3d_armor_inv_leggings_cactus.png", + groups = {armor_legs=5, armor_heal=0, armor_use=1000}, + wear = 0, + }) + minetest.register_tool("3d_armor:boots_cactus", { + description = "Cactus Boots", + inventory_image = "3d_armor_inv_boots_cactus.png", + groups = {armor_feet=5, armor_heal=0, armor_use=2000}, + wear = 0, + }) +end -minetest.register_tool("3d_armor:helmet_wood", { - description = "Wood Helmet", - inventory_image = "3d_armor_inv_helmet_wood.png", - groups = {armor_head=5, armor_heal=0, armor_use=2000}, - wear = 0, -}) +if ARMOR_MATERIALS.steel then + minetest.register_tool("3d_armor:helmet_steel", { + description = "Steel Helmet", + inventory_image = "3d_armor_inv_helmet_steel.png", + groups = {armor_head=10, armor_heal=0, armor_use=500}, + wear = 0, + }) + minetest.register_tool("3d_armor:chestplate_steel", { + description = "Steel Chestplate", + inventory_image = "3d_armor_inv_chestplate_steel.png", + groups = {armor_torso=15, armor_heal=0, armor_use=500}, + wear = 0, + }) + minetest.register_tool("3d_armor:leggings_steel", { + description = "Steel Leggings", + inventory_image = "3d_armor_inv_leggings_steel.png", + groups = {armor_legs=15, armor_heal=0, armor_use=500}, + wear = 0, + }) + minetest.register_tool("3d_armor:boots_steel", { + description = "Steel Boots", + inventory_image = "3d_armor_inv_boots_steel.png", + groups = {armor_feet=10, armor_heal=0, armor_use=500}, + wear = 0, + }) +end -minetest.register_tool("3d_armor:helmet_cactus", { - description = "Cactuc Helmet", - inventory_image = "3d_armor_inv_helmet_cactus.png", - groups = {armor_head=5, armor_heal=0, armor_use=1000}, - wear = 0, -}) +if ARMOR_MATERIALS.bronze then + minetest.register_tool("3d_armor:helmet_bronze", { + description = "Bronze Helmet", + inventory_image = "3d_armor_inv_helmet_bronze.png", + groups = {armor_head=10, armor_heal=6, armor_use=250}, + wear = 0, + }) + minetest.register_tool("3d_armor:chestplate_bronze", { + description = "Bronze Chestplate", + inventory_image = "3d_armor_inv_chestplate_bronze.png", + groups = {armor_torso=15, armor_heal=6, armor_use=250}, + wear = 0, + }) + minetest.register_tool("3d_armor:leggings_bronze", { + description = "Bronze Leggings", + inventory_image = "3d_armor_inv_leggings_bronze.png", + groups = {armor_legs=15, armor_heal=6, armor_use=250}, + wear = 0, + }) + minetest.register_tool("3d_armor:boots_bronze", { + description = "Bronze Boots", + inventory_image = "3d_armor_inv_boots_bronze.png", + groups = {armor_feet=10, armor_heal=6, armor_use=250}, + wear = 0, + }) +end -minetest.register_tool("3d_armor:helmet_steel", { - description = "Steel Helmet", - inventory_image = "3d_armor_inv_helmet_steel.png", - groups = {armor_head=10, armor_heal=0, armor_use=500}, - wear = 0, -}) +if ARMOR_MATERIALS.diamond then + minetest.register_tool("3d_armor:helmet_diamond", { + description = "Diamond Helmet", + inventory_image = "3d_armor_inv_helmet_diamond.png", + groups = {armor_head=15, armor_heal=12, armor_use=100}, + wear = 0, + }) + minetest.register_tool("3d_armor:chestplate_diamond", { + description = "Diamond Chestplate", + inventory_image = "3d_armor_inv_chestplate_diamond.png", + groups = {armor_torso=20, armor_heal=12, armor_use=100}, + wear = 0, + }) + minetest.register_tool("3d_armor:leggings_diamond", { + description = "Diamond Leggings", + inventory_image = "3d_armor_inv_leggings_diamond.png", + groups = {armor_legs=20, armor_heal=12, armor_use=100}, + wear = 0, + }) + minetest.register_tool("3d_armor:boots_diamond", { + description = "Diamond Boots", + inventory_image = "3d_armor_inv_boots_diamond.png", + groups = {armor_feet=15, armor_heal=12, armor_use=100}, + wear = 0, + }) +end -minetest.register_tool("3d_armor:helmet_bronze", { - description = "Bronze Helmet", - inventory_image = "3d_armor_inv_helmet_bronze.png", - groups = {armor_head=10, armor_heal=6, armor_use=250}, - wear = 0, -}) +if ARMOR_MATERIALS.gold then + minetest.register_tool("3d_armor:helmet_gold", { + description = "Gold Helmet", + inventory_image = "3d_armor_inv_helmet_gold.png", + groups = {armor_head=10, armor_heal=6, armor_use=250}, + wear = 0, + }) + minetest.register_tool("3d_armor:chestplate_gold", { + description = "Gold Chestplate", + inventory_image = "3d_armor_inv_chestplate_gold.png", + groups = {armor_torso=15, armor_heal=6, armor_use=250}, + wear = 0, + }) + minetest.register_tool("3d_armor:leggings_gold", { + description = "Gold Leggings", + inventory_image = "3d_armor_inv_leggings_gold.png", + groups = {armor_legs=15, armor_heal=6, armor_use=250}, + wear = 0, + }) + minetest.register_tool("3d_armor:boots_gold", { + description = "Gold Boots", + inventory_image = "3d_armor_inv_boots_gold.png", + groups = {armor_feet=10, armor_heal=6, armor_use=250}, + wear = 0, + }) +end -minetest.register_tool("3d_armor:helmet_diamond", { - description = "Diamond Helmet", - inventory_image = "3d_armor_inv_helmet_diamond.png", - groups = {armor_head=15, armor_heal=12, armor_use=100}, - wear = 0, -}) - -minetest.register_tool("3d_armor:helmet_gold", { - description = "Gold Helmet", - inventory_image = "3d_armor_inv_helmet_gold.png", - groups = {armor_head=10, armor_heal=6, armor_use=250}, - wear = 0, -}) - -if use_moreores then +if ARMOR_MATERIALS.mithril then minetest.register_tool("3d_armor:helmet_mithril", { description = "Mithril Helmet", inventory_image = "3d_armor_inv_helmet_mithril.png", groups = {armor_head=15, armor_heal=12, armor_use=50}, wear = 0, }) -end - --- Regisiter Torso Armor - -minetest.register_tool("3d_armor:chestplate_wood", { - description = "Wood Chestplate", - inventory_image = "3d_armor_inv_chestplate_wood.png", - groups = {armor_torso=10, armor_heal=0, armor_use=2000}, - wear = 0, -}) - -minetest.register_tool("3d_armor:chestplate_cactus", { - description = "Cactus Chestplate", - inventory_image = "3d_armor_inv_chestplate_cactus.png", - groups = {armor_torso=10, armor_heal=0, armor_use=1000}, - wear = 0, -}) - -minetest.register_tool("3d_armor:chestplate_steel", { - description = "Steel Chestplate", - inventory_image = "3d_armor_inv_chestplate_steel.png", - groups = {armor_torso=15, armor_heal=0, armor_use=500}, - wear = 0, -}) - -minetest.register_tool("3d_armor:chestplate_bronze", { - description = "Bronze Chestplate", - inventory_image = "3d_armor_inv_chestplate_bronze.png", - groups = {armor_torso=15, armor_heal=6, armor_use=250}, - wear = 0, -}) - -minetest.register_tool("3d_armor:chestplate_diamond", { - description = "Diamond Chestplate", - inventory_image = "3d_armor_inv_chestplate_diamond.png", - groups = {armor_torso=20, armor_heal=12, armor_use=100}, - wear = 0, -}) - -minetest.register_tool("3d_armor:chestplate_gold", { - description = "Gold Chestplate", - inventory_image = "3d_armor_inv_chestplate_gold.png", - groups = {armor_torso=15, armor_heal=6, armor_use=250}, - wear = 0, -}) - -if use_moreores then minetest.register_tool("3d_armor:chestplate_mithril", { description = "Mithril Chestplate", inventory_image = "3d_armor_inv_chestplate_mithril.png", groups = {armor_torso=20, armor_heal=12, armor_use=50}, wear = 0, }) -end - --- Regisiter Leg Armor - -minetest.register_tool("3d_armor:leggings_wood", { - description = "Wood Leggings", - inventory_image = "3d_armor_inv_leggings_wood.png", - groups = {armor_legs=5, armor_heal=0, armor_use=2000}, - wear = 0, -}) - -minetest.register_tool("3d_armor:leggings_cactus", { - description = "Cactus Leggings", - inventory_image = "3d_armor_inv_leggings_cactus.png", - groups = {armor_legs=5, armor_heal=0, armor_use=1000}, - wear = 0, -}) - -minetest.register_tool("3d_armor:leggings_steel", { - description = "Steel Leggings", - inventory_image = "3d_armor_inv_leggings_steel.png", - groups = {armor_legs=15, armor_heal=0, armor_use=500}, - wear = 0, -}) - -minetest.register_tool("3d_armor:leggings_bronze", { - description = "Bronze Leggings", - inventory_image = "3d_armor_inv_leggings_bronze.png", - groups = {armor_legs=15, armor_heal=6, armor_use=250}, - wear = 0, -}) - -minetest.register_tool("3d_armor:leggings_diamond", { - description = "Diamond Leggings", - inventory_image = "3d_armor_inv_leggings_diamond.png", - groups = {armor_legs=20, armor_heal=12, armor_use=100}, - wear = 0, -}) - -minetest.register_tool("3d_armor:leggings_gold", { - description = "Gold Leggings", - inventory_image = "3d_armor_inv_leggings_gold.png", - groups = {armor_legs=15, armor_heal=6, armor_use=250}, - wear = 0, -}) - -if use_moreores then minetest.register_tool("3d_armor:leggings_mithril", { description = "Mithril Leggings", inventory_image = "3d_armor_inv_leggings_mithril.png", groups = {armor_legs=20, armor_heal=12, armor_use=50}, wear = 0, }) -end - --- Regisiter Boots - -minetest.register_tool("3d_armor:boots_wood", { - description = "Wood Boots", - inventory_image = "3d_armor_inv_boots_wood.png", - groups = {armor_feet=5, armor_heal=0, armor_use=2000}, - wear = 0, -}) - -minetest.register_tool("3d_armor:boots_cactus", { - description = "Cactus Boots", - inventory_image = "3d_armor_inv_boots_cactus.png", - groups = {armor_feet=5, armor_heal=0, armor_use=2000}, - wear = 0, -}) - -minetest.register_tool("3d_armor:boots_steel", { - description = "Steel Boots", - inventory_image = "3d_armor_inv_boots_steel.png", - groups = {armor_feet=10, armor_heal=0, armor_use=500}, - wear = 0, -}) - -minetest.register_tool("3d_armor:boots_bronze", { - description = "Bronze Boots", - inventory_image = "3d_armor_inv_boots_bronze.png", - groups = {armor_feet=10, armor_heal=6, armor_use=250}, - wear = 0, -}) - -minetest.register_tool("3d_armor:boots_diamond", { - description = "Diamond Boots", - inventory_image = "3d_armor_inv_boots_diamond.png", - groups = {armor_feet=15, armor_heal=12, armor_use=100}, - wear = 0, -}) - -minetest.register_tool("3d_armor:boots_gold", { - description = "Gold Boots", - inventory_image = "3d_armor_inv_boots_gold.png", - groups = {armor_feet=10, armor_heal=6, armor_use=250}, - wear = 0, -}) - -if use_moreores then minetest.register_tool("3d_armor:boots_mithril", { description = "Mithril Boots", inventory_image = "3d_armor_inv_boots_mithril.png", @@ -216,22 +191,7 @@ if use_moreores then }) end --- Register Craft Recipies - -local craft_ingreds = { - wood = "default:wood", - cactus = "default:cactus", - steel = "default:steel_ingot", - bronze = "default:bronze_ingot", - diamond = "default:diamond", - gold = "default:gold_ingot", -} - -if use_moreores then - craft_ingreds.mithril = "moreores:mithril_ingot" -end - -for k, v in pairs(craft_ingreds) do +for k, v in pairs(ARMOR_MATERIALS) do minetest.register_craft({ output = "3d_armor:helmet_"..k, recipe = {