init.lua 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. local function make_new_groups(groups)
  2. local newgroups = --comment
  3. {
  4. level = groups.level or 1,
  5. snappy = groups.snappy or 0,
  6. choppy = groups.choppy or 0,
  7. cracky = groups.cracky or 0,
  8. crumbly = groups.crumbly or 0,
  9. flammable = groups.flammable or 0,
  10. }
  11. return newgroups
  12. end
  13. local register_reinforce = function(basename)
  14. local ndef = minetest.registered_nodes[basename]
  15. assert(type(ndef) == "table")
  16. -- Reinforced X.
  17. do
  18. local itemname = string.split(basename, ":")[2]
  19. local realname = "dk_reinforced:" .. itemname
  20. local reinforced = table.copy(ndef)
  21. reinforced.description = "Reinforced " .. ndef.description
  22. for i, tile in ipairs(reinforced.tiles) do
  23. reinforced.tiles[i] = tile .. "^darkage_reinforce.png"
  24. end
  25. -- Don't inherit groups from parent node.
  26. reinforced.groups = make_new_groups(reinforced.groups or {})
  27. minetest.register_node(realname, reinforced)
  28. minetest.register_craft({
  29. output = realname,
  30. recipe = {
  31. {"group:stick", "", "group:stick"},
  32. {"", basename, ""},
  33. {"group:stick", "", "group:stick"},
  34. }
  35. })
  36. -- Recycling.
  37. minetest.register_craft({
  38. type = "shapeless",
  39. output = basename,
  40. recipe = {realname},
  41. })
  42. end
  43. -- Reinforced Window.
  44. do
  45. local itemname = string.split(basename, ":")[2]
  46. local realname = "dk_reinforced:" .. itemname .. "_cross"
  47. local reinforced = table.copy(ndef)
  48. reinforced.description = "Reinforced " .. ndef.description .. " Cross"
  49. for i, tile in ipairs(reinforced.tiles) do
  50. reinforced.tiles[i] = tile .. "^darkage_reinforce_window.png"
  51. end
  52. -- Don't inherit groups from parent node.
  53. reinforced.groups = make_new_groups(reinforced.groups or {})
  54. minetest.register_node(realname, reinforced)
  55. minetest.register_craft({
  56. output = realname,
  57. recipe = {
  58. {"", "group:stick", ""},
  59. {"group:stick", basename, "group:stick"},
  60. {"", "group:stick", ""},
  61. }
  62. })
  63. -- Recycling.
  64. minetest.register_craft({
  65. type = "shapeless",
  66. output = basename,
  67. recipe = {realname},
  68. })
  69. end
  70. -- Reinforced Slope.
  71. do
  72. local itemname = string.split(basename, ":")[2]
  73. local realname = "dk_reinforced:" .. itemname .. "_slope"
  74. local slope = table.copy(ndef)
  75. slope.description = "Reinforced " .. ndef.description .. " Slope"
  76. slope.paramtype2 = "facedir"
  77. -- Don't inherit groups from parent node.
  78. slope.groups = make_new_groups(slope.groups or {})
  79. local slope_tile_extend = {
  80. "^darkage_reinforce_right.png",
  81. "^darkage_reinforce_right.png",
  82. "^darkage_reinforce_right.png",
  83. "^darkage_reinforce_right.png",
  84. "^darkage_reinforce_left.png",
  85. "^darkage_reinforce_left.png",
  86. }
  87. for i = 1, 6 do
  88. local tile = slope.tiles[i] or ndef.tiles[1]
  89. slope.tiles[i] = tile .. slope_tile_extend[i]
  90. end
  91. minetest.register_node(realname, slope)
  92. minetest.register_craft({
  93. output = realname,
  94. recipe = {
  95. {"group:stick", "", ""},
  96. {"", basename, ""},
  97. {"", "", "group:stick"},
  98. }
  99. })
  100. -- Recycling.
  101. minetest.register_craft({
  102. type = "shapeless",
  103. output = basename,
  104. recipe = {realname},
  105. })
  106. end
  107. -- Arrow bar.
  108. do
  109. local itemname = string.split(basename, ":")[2]
  110. local realname = "dk_reinforced:" .. itemname .. "_arrow"
  111. local arrow = table.copy(ndef)
  112. arrow.paramtype2 = "facedir"
  113. arrow.description = "Reinforced " .. ndef.description .. " Arrow"
  114. -- Don't inherit groups from parent node.
  115. arrow.groups = make_new_groups(arrow.groups or {})
  116. local arrow_tile_extend = {
  117. "^darkage_reinforce_bars.png",
  118. "^darkage_reinforce_bars.png",
  119. "^(darkage_reinforce_arrow.png^[transformR90)",
  120. "^(darkage_reinforce_arrow.png^[transformR270)",
  121. "^(darkage_reinforce_arrow.png^[transformR180)",
  122. "^darkage_reinforce_arrow.png",
  123. }
  124. for i = 1, 6 do
  125. local tile = arrow.tiles[i] or ndef.tiles[1]
  126. arrow.tiles[i] = tile .. arrow_tile_extend[i]
  127. end
  128. minetest.register_node(realname, arrow)
  129. minetest.register_craft({
  130. output = realname,
  131. recipe = {
  132. {"", "group:stick", ""},
  133. {"", basename, ""},
  134. {"group:stick", "", "group:stick"},
  135. }
  136. })
  137. -- Recycling
  138. minetest.register_craft({
  139. type = "shapeless",
  140. output = basename,
  141. recipe = {realname}
  142. })
  143. end
  144. -- Reinforced Bars.
  145. do
  146. local itemname = string.split(basename, ":")[2]
  147. local realname = "dk_reinforced:" .. itemname .. "_bars"
  148. local bars = table.copy(ndef)
  149. bars.description = "Reinforced " .. ndef.description .. " Bars"
  150. for i, tile in ipairs(bars.tiles) do
  151. bars.tiles[i] = tile .. "^darkage_reinforce_bars.png"
  152. end
  153. -- Don't inherit groups from parent node.
  154. bars.groups = make_new_groups(bars.groups or {})
  155. minetest.register_node(realname, bars)
  156. minetest.register_craft({
  157. output = realname,
  158. recipe = {
  159. {"group:stick", "", "group:stick"},
  160. {"group:stick", basename, "group:stick"},
  161. {"group:stick", "", "group:stick"},
  162. }
  163. })
  164. -- Recycling
  165. minetest.register_craft({
  166. type = "shapeless",
  167. output = basename,
  168. recipe = {realname}
  169. })
  170. end
  171. end
  172. register_reinforce("basictrees:tree_wood")
  173. register_reinforce("basictrees:jungletree_wood")
  174. register_reinforce("basictrees:aspen_wood")
  175. register_reinforce("basictrees:pine_wood")
  176. register_reinforce("firetree:whitewood")
  177. register_reinforce("firetree:firewood")
  178. register_reinforce("jungletree:jungletree_wood")
  179. register_reinforce("moretrees:cedar_wood")
  180. register_reinforce("moretrees:apple_tree_wood")
  181. register_reinforce("moretrees:fir_wood")
  182. register_reinforce("moretrees:oak_wood")
  183. register_reinforce("moretrees:spruce_wood")
  184. register_reinforce("moretrees:palm_wood")
  185. register_reinforce("moretrees:rubber_tree_wood")
  186. register_reinforce("moretrees:poplar_wood")
  187. register_reinforce("moretrees:beech_wood")
  188. register_reinforce("moretrees:sequoia_wood")
  189. register_reinforce("moretrees:willow_wood")
  190. register_reinforce("moretrees:date_palm_wood")
  191. register_reinforce("moretrees:jungletree_wood")
  192. register_reinforce("moretrees:birch_wood")
  193. register_reinforce("darkage:chalk")
  194. register_reinforce("darkage:chalked_bricks")
  195. register_reinforce("default:clay")
  196. register_reinforce("default:sandstone")
  197. register_reinforce("moreblocks:tar")
  198. register_reinforce("glowstone:glowstone")
  199. register_reinforce("glowstone:minerals")
  200. register_reinforce("luxore:luxore")
  201. register_reinforce("glowstone:cobble")