init.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. local use_moreores = minetest.get_modpath("moreores")
  2. -- Register Shields
  3. local function register_shield(name, data)
  4. data._armor_resist_groups = sysdmg.get_armor_resist_for(name)
  5. data._armor_wear_groups = sysdmg.get_armor_wear_for(name)
  6. if not data.groups then
  7. data.groups = {armor_shield=1}
  8. else
  9. data.groups.armor_shield = 1
  10. end
  11. data.groups = sysdmg.get_armor_groups_for(name, data.groups)
  12. minetest.register_tool(name, data)
  13. end
  14. if ARMOR_MATERIALS.wood then
  15. register_shield("shields:shield_wood", {
  16. description = "Wooden Shield",
  17. inventory_image = "shields_inv_shield_wood.png",
  18. })
  19. register_shield("shields:shield_enhanced_wood", {
  20. description = "Enhanced Wood Shield",
  21. inventory_image = "shields_inv_shield_enhanced_wood.png",
  22. })
  23. minetest.register_craft({
  24. output = "shields:shield_enhanced_wood",
  25. recipe = {
  26. {"default:steel_ingot"},
  27. {"shields:shield_wood"},
  28. {"default:steel_ingot"},
  29. },
  30. })
  31. minetest.register_craft({
  32. type = "cooking",
  33. output = "default:steel_ingot 2",
  34. recipe = "shields:shield_enhanced_wood",
  35. })
  36. end
  37. if ARMOR_MATERIALS.steel then
  38. register_shield("shields:shield_steel", {
  39. description = "Wrought Iron Shield",
  40. inventory_image = "shields_inv_shield_steel.png",
  41. })
  42. end
  43. if ARMOR_MATERIALS.carbon then
  44. register_shield("shields:shield_carbon", {
  45. description = "Carbon Steel Shield",
  46. inventory_image = "shields_inv_shield_carbon.png",
  47. })
  48. end
  49. if ARMOR_MATERIALS.bronze then
  50. register_shield("shields:shield_bronze", {
  51. description = "Bronze Shield",
  52. inventory_image = "shields_inv_shield_bronze.png",
  53. })
  54. end
  55. if ARMOR_MATERIALS.diamond then
  56. register_shield("shields:shield_diamond", {
  57. description = "Diamond Shield",
  58. inventory_image = "shields_inv_shield_diamond.png",
  59. })
  60. end
  61. if ARMOR_MATERIALS.gold then
  62. register_shield("shields:shield_gold", {
  63. description = "Golden Shield",
  64. inventory_image = "shields_inv_shield_gold.png",
  65. })
  66. end
  67. if ARMOR_MATERIALS.mithril then
  68. register_shield("shields:shield_mithril", {
  69. description = "Mithril Shield",
  70. inventory_image = "shields_inv_shield_mithril.png",
  71. })
  72. end
  73. for k, v in pairs(ARMOR_MATERIALS) do
  74. local center = "techcrafts:composite_plate"
  75. if string.find(v, "wood") then
  76. center = "default:steel_ingot"
  77. end
  78. minetest.register_craft({
  79. output = "shields:shield_"..k,
  80. recipe = {
  81. {v, "mobs:leather_padding", v},
  82. {v, center, v},
  83. {"", v, ""},
  84. },
  85. })
  86. -- Reverse cooking recipes for all shields except wood and diamond.
  87. if not string.find(v, "wood") and not string.find(v, "diamond") and string.find(v, "ingot") then
  88. minetest.register_craft({
  89. type = "cooking",
  90. output = v .. " 5",
  91. recipe = "shields:shield_" .. k,
  92. cooktime = 15,
  93. })
  94. end
  95. if string.find(v, "wood") then
  96. minetest.register_craft({
  97. type = "fuel",
  98. recipe = "shields:shield_" .. k,
  99. burntime = 5,
  100. })
  101. end
  102. end
  103. minetest.after(0, function()
  104. table.insert(armor.elements, "shield")
  105. end)