stairs.lua 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. --[[
  2. More Blocks: stair definitions
  3. Copyright (c) 2011-2017 Hugo Locurcio and contributors.
  4. Licensed under the zlib license. See LICENSE.md for more information.
  5. --]]
  6. local S = moreblocks.intllib
  7. -- Node will be called <modname>:stair_<subname>
  8. function register_stair(modname, subname, recipeitem, groups, images, description, drop, light)
  9. stairsplus:register_stair(modname, subname, recipeitem, {
  10. groups = groups,
  11. tiles = images,
  12. description = description,
  13. drop = drop,
  14. light_source = light,
  15. sounds = default.node_sound_stone_defaults(),
  16. })
  17. end
  18. local stairs_defs = {
  19. [""] = {
  20. node_box = {
  21. type = "fixed",
  22. fixed = {
  23. {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
  24. {-0.5, 0, 0, 0.5, 0.5, 0.5},
  25. },
  26. },
  27. },
  28. ["_half"] = {
  29. node_box = {
  30. type = "fixed",
  31. fixed = {
  32. {-0.5, -0.5, -0.5, 0, 0, 0.5},
  33. {-0.5, 0, 0, 0, 0.5, 0.5},
  34. },
  35. },
  36. },
  37. ["_right_half" ]= {
  38. node_box = {
  39. type = "fixed",
  40. fixed = {
  41. {0, -0.5, -0.5, 0.5, 0, 0.5},
  42. {0, 0, 0, 0.5, 0.5, 0.5},
  43. },
  44. },
  45. },
  46. ["_inner"] = {
  47. node_box = {
  48. type = "fixed",
  49. fixed = {
  50. {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
  51. {-0.5, 0, 0, 0.5, 0.5, 0.5},
  52. {-0.5, 0, -0.5, 0, 0.5, 0},
  53. },
  54. },
  55. },
  56. ["_outer"] = {
  57. node_box = {
  58. type = "fixed",
  59. fixed = {
  60. {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
  61. {-0.5, 0, 0, 0, 0.5, 0.5},
  62. },
  63. },
  64. },
  65. ["_alt"] = {
  66. node_box = {
  67. type = "fixed",
  68. fixed = {
  69. {-0.5, -0.5, -0.5, 0.5, 0, 0},
  70. {-0.5, 0, 0, 0.5, 0.5, 0.5},
  71. },
  72. },
  73. },
  74. ["_alt_1"] = {
  75. node_box = {
  76. type = "fixed",
  77. fixed = {
  78. {-0.5, -0.0625, -0.5, 0.5, 0, 0},
  79. {-0.5, 0.4375, 0, 0.5, 0.5, 0.5},
  80. },
  81. },
  82. },
  83. ["_alt_2"] = {
  84. node_box = {
  85. type = "fixed",
  86. fixed = {
  87. {-0.5, -0.125, -0.5, 0.5, 0, 0},
  88. {-0.5, 0.375, 0, 0.5, 0.5, 0.5},
  89. },
  90. },
  91. },
  92. ["_alt_4"] = {
  93. node_box = {
  94. type = "fixed",
  95. fixed = {
  96. {-0.5, -0.25, -0.5, 0.5, 0, 0},
  97. {-0.5, 0.25, 0, 0.5, 0.5, 0.5},
  98. },
  99. },
  100. },
  101. }
  102. for k,v in pairs(stairs_defs) do
  103. table.insert(stairsplus.shapes_list, { "stair_", k })
  104. end
  105. function stairsplus:register_stair_alias(modname_old, subname_old, modname_new, subname_new)
  106. local defs = stairsplus.copytable(stairs_defs)
  107. for alternate, def in pairs(defs) do
  108. minetest.register_alias(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate)
  109. end
  110. end
  111. function stairsplus:register_stair_alias_force(modname_old, subname_old, modname_new, subname_new)
  112. local defs = stairsplus.copytable(stairs_defs)
  113. for alternate, def in pairs(defs) do
  114. minetest.register_alias_force(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate)
  115. end
  116. end
  117. function stairsplus:register_stair(modname, subname, recipeitem, fields)
  118. local defs = stairsplus.copytable(stairs_defs)
  119. local desc = S("%s Stairs"):format(fields.description)
  120. local use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "blend" or fields.use_texture_alpha
  121. for alternate, def in pairs(defs) do
  122. for k, v in pairs(fields) do
  123. def[k] = v
  124. end
  125. def.drawtype = "nodebox"
  126. def.paramtype = "light"
  127. def.paramtype2 = def.paramtype2 or "facedir"
  128. def.use_texture_alpha = use_texture_alpha
  129. def.on_place = minetest.rotate_node
  130. def.description = desc
  131. def.groups = stairsplus:prepare_groups(fields.groups)
  132. if fields.drop and not (type(fields.drop) == "table") then
  133. def.drop = modname .. ":stair_" .. fields.drop .. alternate
  134. end
  135. minetest.register_node(":" .. modname .. ":stair_" .. subname .. alternate, def)
  136. end
  137. minetest.register_alias("stairs:stair_" .. subname, modname .. ":stair_" .. subname)
  138. circular_saw.known_nodes[recipeitem] = {modname, subname}
  139. -- Some saw-less recipes:
  140. minetest.register_craft({
  141. output = modname .. ":stair_" .. subname .. " 8",
  142. recipe = {
  143. {recipeitem, "", ""},
  144. {recipeitem, recipeitem, ""},
  145. {recipeitem, recipeitem, recipeitem},
  146. },
  147. })
  148. minetest.register_craft({
  149. output = modname .. ":stair_" .. subname .. " 8",
  150. recipe = {
  151. {"", "", recipeitem},
  152. {"", recipeitem, recipeitem},
  153. {recipeitem, recipeitem, recipeitem},
  154. },
  155. })
  156. minetest.register_craft({
  157. type = "shapeless",
  158. output = modname .. ":stair_" .. subname,
  159. recipe = {modname .. ":panel_" .. subname, modname .. ":slab_" .. subname},
  160. })
  161. minetest.register_craft({
  162. type = "shapeless",
  163. output = modname .. ":stair_" .. subname,
  164. recipe = {modname .. ":panel_" .. subname, modname .. ":panel_" .. subname, modname .. ":panel_" .. subname},
  165. })
  166. minetest.register_craft({
  167. type = "shapeless",
  168. output = modname .. ":stair_" .. subname .. "_outer",
  169. recipe = {modname .. ":micro_" .. subname, modname .. ":slab_" .. subname},
  170. })
  171. minetest.register_craft({
  172. type = "shapeless",
  173. output = modname .. ":stair_" .. subname .. "_half",
  174. recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname},
  175. })
  176. minetest.register_craft({
  177. type = "shapeless",
  178. output = modname .. ":stair_" .. subname .. "_half",
  179. recipe = {modname .. ":panel_" .. subname, modname .. ":micro_" .. subname},
  180. })
  181. minetest.register_craft({
  182. type = "shapeless",
  183. output = modname .. ":stair_" .. subname .. "_right_half",
  184. recipe = {modname .. ":stair_" .. subname .. "_half"},
  185. })
  186. minetest.register_craft({
  187. type = "shapeless",
  188. output = modname .. ":stair_" .. subname,
  189. recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname},
  190. })
  191. minetest.register_craft({
  192. type = "shapeless",
  193. output = modname .. ":stair_" .. subname .. "_inner",
  194. recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname},
  195. })
  196. minetest.register_craft({
  197. type = "shapeless",
  198. output = modname .. ":stair_" .. subname .. "_outer",
  199. recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname},
  200. })
  201. minetest.register_craft({
  202. type = "shapeless",
  203. output = modname .. ":stair_" .. subname,
  204. recipe = {modname .. ":panel_" .. subname, modname .. ":panel_" .. subname, modname .. ":panel_" .. subname},
  205. })
  206. minetest.register_craft({ -- See mirrored variation of the recipe below.
  207. output = modname .. ":stair_" .. subname .. "_alt",
  208. recipe = {
  209. {modname .. ":panel_" .. subname, ""},
  210. {"" , modname .. ":panel_" .. subname},
  211. },
  212. })
  213. minetest.register_craft({ -- Mirrored variation of the recipe above.
  214. output = modname .. ":stair_" .. subname .. "_alt",
  215. recipe = {
  216. {"" , modname .. ":panel_" .. subname},
  217. {modname .. ":panel_" .. subname, ""},
  218. },
  219. })
  220. end