building.lua 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. --[[
  2. This function registers the nodes and craft rezieps for the reinforce stuff
  3. * name: String which is used in description and as technical name (lower letters)
  4. * craftItem: the Item where the reinforce is crafted out of
  5. * nodedef: Nodedefinition table as used as in minetest.register_node()
  6. The Nodes are caled
  7. <modname>:reinforced_<name>
  8. <modname>:reinforced_<name>_slope
  9. <modname>:reinforced_<name>_arrow
  10. <modname>:reinforced_<name>_bars
  11. The modname is automatically the mod that currently calls this function.
  12. e.g. if you call darkage.register_reinforce from the mod medieval modname will be medieval
  13. ]]
  14. function darkage.register_reinforce(name, craftItem, nodedef)
  15. assert(type(nodedef.tiles)=="table","ERRROR: nodedef.tiles have to be a table")
  16. assert(nodedef.tiles[1], "ERROR: "..dump(nodedef.tiles).." requires at least 1 entry")
  17. local modname = minetest.get_current_modname();
  18. local tname = name:lower(); -- Technical name
  19. -- Reinforced X
  20. local reinforced = table.copy(nodedef);
  21. local reinforced_tname = modname..":reinforced_"..tname
  22. reinforced.description = "Reinforced "..name
  23. for i,tile in ipairs(reinforced.tiles) do
  24. reinforced.tiles[i] = tile .."^darkage_reinforce.png"
  25. end
  26. minetest.register_node(reinforced_tname, reinforced)
  27. minetest.register_craft({
  28. output = reinforced_tname,
  29. recipe = {
  30. {"group:stick", craftItem, "group:stick"},
  31. {craftItem, "group:stick", craftItem},
  32. {"group:stick", craftItem, "group:stick"},
  33. }
  34. })
  35. -- Recycling
  36. minetest.register_craft({
  37. output = craftItem,
  38. recipe = {
  39. { reinforced_tname },
  40. }
  41. })
  42. -- Reinforced Slope
  43. local slope = table.copy(nodedef);
  44. local slope_tname = modname..":reinforced_"..tname.."_slope"
  45. slope.description = "Reinforced "..name.." Slope"
  46. slope.paramtype2 = "facedir";
  47. local slope_tile_extend = {"^darkage_reinforce_right.png" , "^darkage_reinforce_right.png" , --top ,down
  48. "^darkage_reinforce_right.png" , "^darkage_reinforce_right.png" , --right, left
  49. "^darkage_reinforce_left.png" , "^darkage_reinforce_left.png"} -- front, back
  50. for i=1,6 do
  51. local tile = slope.tiles[i] or nodedef.tiles[1]; -- There have to be at least one tile.
  52. slope.tiles[i] = tile ..slope_tile_extend[i]
  53. end
  54. minetest.register_node(slope_tname, slope)
  55. minetest.register_craft({
  56. output = slope_tname,
  57. recipe = {
  58. {craftItem, craftItem, "group:stick"},
  59. {craftItem, "group:stick", craftItem},
  60. {"group:stick", craftItem, craftItem},
  61. }
  62. })
  63. -- Flipped recipe
  64. minetest.register_craft({
  65. output = slope_tname,
  66. recipe = {
  67. {"group:stick", craftItem, craftItem},
  68. {craftItem, "group:stick", craftItem},
  69. {craftItem, craftItem, "group:stick"},
  70. }
  71. })
  72. -- Recycling
  73. minetest.register_craft({
  74. output = craftItem,
  75. recipe = {
  76. { slope_tname }
  77. }
  78. })
  79. -- Alias to convert old nodes
  80. minetest.register_alias(modname..":reinforced_"..tname.."_right", slope_tname)
  81. minetest.register_alias(modname..":reinforced_"..tname.."_left", slope_tname)
  82. -- Arrow bar
  83. local arrow = table.copy(nodedef)
  84. local arrow_tname = modname..":reinforced_"..tname.."_arrow"
  85. arrow.paramtype2 = "facedir";
  86. arrow.description = "Reinforced "..name.." Arrow"
  87. local arrow_tile_extend = {"" , "" , --top ,down
  88. "^(darkage_reinforce_arrow.png^[transformR90)" , "^(darkage_reinforce_arrow.png^[transformR270)" , --right, left
  89. "^(darkage_reinforce_arrow.png^[transformR180)" , "^darkage_reinforce_arrow.png"} -- front, back
  90. for i=1,6 do
  91. local tile = arrow.tiles[i] or arrow.tiles[1]; -- There have to be at least one tile.
  92. arrow.tiles[i] = tile .. arrow_tile_extend[i]
  93. end
  94. minetest.register_node(arrow_tname, arrow)
  95. minetest.register_craft({
  96. output = arrow_tname,
  97. recipe = {
  98. {craftItem, "group:stick", craftItem},
  99. {"group:stick", craftItem, "group:stick"},
  100. {"group:stick", craftItem, "group:stick"},
  101. }
  102. })
  103. -- Recycling
  104. minetest.register_craft({
  105. output = craftItem,
  106. recipe = {
  107. { arrow_tname }
  108. }
  109. })
  110. -- Reinforced Bars
  111. local bars = table.copy(nodedef)
  112. local bars_tname = modname..":reinforced_"..tname.."_bars"
  113. bars.description = name.." Bars"
  114. for i,tile in ipairs(bars.tiles) do
  115. bars.tiles[i] = tile .."^darkage_reinforce_bars.png"
  116. end
  117. minetest.register_node(bars_tname, bars)
  118. minetest.register_craft({
  119. output = bars_tname,
  120. recipe = {
  121. {"group:stick", craftItem, "group:stick"},
  122. {"group:stick", craftItem, "group:stick"},
  123. {"group:stick", craftItem, "group:stick"},
  124. }
  125. })
  126. minetest.register_craft({
  127. output = craftItem,
  128. recipe = {
  129. { bars_tname }
  130. }
  131. })
  132. end
  133. darkage.register_reinforce("Chalk", "darkage:chalk_powder", {
  134. tiles = {"darkage_chalk.png"},
  135. groups = {cracky=3},
  136. sounds = default.node_sound_stone_defaults()
  137. })
  138. darkage.register_reinforce("Wood", "default:wood", {
  139. tiles = {"default_wood.png"},
  140. groups = {snappy=2, choppy=3, flammable=3},
  141. sounds = default.node_sound_wood_defaults()
  142. })
  143. minetest.register_node("darkage:glass", {
  144. description = "Medieval Glass",
  145. drawtype = "glasslike",
  146. tiles = {"darkage_glass.png"},
  147. use_texture_alpha=true,
  148. paramtype = "light",
  149. sunlight_propagates = true,
  150. groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
  151. sounds = default.node_sound_glass_defaults(),
  152. })
  153. minetest.register_node("darkage:glow_glass", {
  154. description = "Medieval Glow Glass",
  155. drawtype = "glasslike",
  156. tiles = {"darkage_glass.png"},
  157. use_texture_alpha=true,
  158. paramtype = "light",
  159. sunlight_propagates = true,
  160. light_source = LIGHT_MAX-1,
  161. groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
  162. sounds = default.node_sound_glass_defaults(),
  163. })
  164. minetest.register_craft({
  165. output = "darkage:glow_glass 1",
  166. recipe = {
  167. {"darkage:glass", "", ""},
  168. {"default:torch", "", ""},
  169. {"", "", ""},
  170. }
  171. })
  172. minetest.register_craft({
  173. output = "darkage:glass 1",
  174. recipe = {
  175. {"darkage:glow_glass"},
  176. }
  177. })
  178. minetest.register_craft({
  179. output = "darkage:glass 8",
  180. recipe = {
  181. {"default:glass", "default:steel_ingot", "default:glass"},
  182. {"default:steel_ingot", "default:glass", "default:steel_ingot"},
  183. {"default:glass", "default:steel_ingot", "default:glass"},
  184. }
  185. })
  186. minetest.register_craft({
  187. output = "darkage:chalk",
  188. recipe = {
  189. {"darkage:chalk_powder","darkage:chalk_powder"},
  190. {"darkage:chalk_powder","darkage:chalk_powder"},
  191. }
  192. })
  193. minetest.register_craft({
  194. output = "darkage:glow_glass 1",
  195. recipe = {
  196. {"darkage:glass", "", ""},
  197. {"default:torch", "", ""},
  198. {"", "", ""},
  199. }
  200. })
  201. minetest.register_craft({
  202. output = "darkage:glass 1",
  203. recipe = {
  204. {"darkage:glow_glass"},
  205. }
  206. })