nodeboxes.lua 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. local S = core.get_translator("testnodes")
  2. -- Nodebox examples and tests.
  3. -- An simple example nodebox with one centered box
  4. core.register_node("testnodes:nodebox_fixed", {
  5. description = S("Fixed Nodebox Test Node").."\n"..
  6. S("Nodebox is always the same"),
  7. tiles = {"testnodes_nodebox.png"},
  8. drawtype = "nodebox",
  9. paramtype = "light",
  10. node_box = {
  11. type = "fixed",
  12. fixed = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
  13. },
  14. groups = {dig_immediate=3},
  15. })
  16. -- 50% higher than a regular node
  17. core.register_node("testnodes:nodebox_overhigh", {
  18. description = S("+50% high Nodebox Test Node"),
  19. tiles = {"testnodes_nodebox.png"},
  20. drawtype = "nodebox",
  21. paramtype = "light",
  22. node_box = {
  23. type = "fixed",
  24. fixed = {-0.5, -0.5, -0.5, 0.5, 1, 0.5},
  25. },
  26. groups = {dig_immediate=3},
  27. })
  28. -- 95% higher than a regular node
  29. core.register_node("testnodes:nodebox_overhigh2", {
  30. description = S("+95% high Nodebox Test Node"),
  31. tiles = {"testnodes_nodebox.png"},
  32. drawtype = "nodebox",
  33. paramtype = "light",
  34. node_box = {
  35. type = "fixed",
  36. -- Y max: more is possible, but glitchy
  37. fixed = {-0.5, -0.5, -0.5, 0.5, 1.45, 0.5},
  38. },
  39. groups = {dig_immediate=3},
  40. })
  41. -- Height of nodebox changes with its param2 value
  42. core.register_node("testnodes:nodebox_leveled", {
  43. description = S("Leveled Nodebox Test Node").."\n"..
  44. S("param2 = height (0..127)"),
  45. tiles = {"testnodes_nodebox.png^[colorize:#0F0:32"},
  46. drawtype = "nodebox",
  47. paramtype = "light",
  48. paramtype2 = "leveled",
  49. node_box = {
  50. type = "leveled",
  51. fixed = {-0.5, 0.0, -0.5, 0.5, -0.499, 0.5},
  52. },
  53. groups = {dig_immediate=3},
  54. })
  55. local nodebox_wall = {
  56. type = "connected",
  57. fixed = {-0.125, -0.500, -0.125, 0.125, 0.500, 0.125},
  58. connect_front = {-0.125, -0.500, -0.500, 0.125, 0.400, -0.125},
  59. connect_back = {-0.125, -0.500, 0.125, 0.125, 0.400, 0.500},
  60. connect_left = {-0.500, -0.500, -0.125, -0.125, 0.400, 0.125},
  61. connect_right = {0.125, -0.500, -0.125, 0.500, 0.400, 0.125},
  62. }
  63. local nodebox_cable = {
  64. type = "connected",
  65. fixed = {-2/16, -2/16, -2/16, 2/16, 2/16, 2/16},
  66. connect_front = {-1/16, -1/16, -8/16, 1/16, 1/16, -2/16},
  67. connect_back = {-1/16, -1/16, 2/16, 1/16, 1/16, 8/16},
  68. connect_left = {-8/16, -1/16, -1/16, -2/16, 1/16, 1/16},
  69. connect_right = { 2/16, -1/16, -1/16, 8/16, 1/16, 1/16},
  70. connect_bottom = {-1/16, -8/16, -1/16, 1/16, -2/16, 1/16},
  71. connect_top = {-1/16, 2/16, -1/16, 1/16, 8/16, 1/16},
  72. }
  73. local nodebox_wall_thick = {
  74. type = "connected",
  75. fixed = {-0.25, -0.500, -0.25, 0.25, 0.500, 0.25},
  76. connect_front = {-0.25, -0.500, -0.500, 0.25, 0.400, -0.25},
  77. connect_back = {-0.25, -0.500, 0.25, 0.25, 0.400, 0.500},
  78. connect_left = {-0.500, -0.500, -0.25, -0.25, 0.400, 0.25},
  79. connect_right = {0.25, -0.500, -0.25, 0.500, 0.400, 0.25},
  80. }
  81. -- Wall-like nodebox that connects to 4 neighbors
  82. core.register_node("testnodes:nodebox_connected", {
  83. description = S("Connected Nodebox Test Node (4 Side Wall)").."\n"..
  84. S("Connects to 4 neighbors sideways"),
  85. tiles = {"testnodes_nodebox.png^[colorize:#F00:32"},
  86. groups = {connected_nodebox=1, dig_immediate=3},
  87. drawtype = "nodebox",
  88. paramtype = "light",
  89. connects_to = {"group:connected_nodebox"},
  90. connect_sides = {"front", "back", "left", "right"},
  91. node_box = nodebox_wall,
  92. })
  93. -- Cable-like nodebox that connects to 6 neighbors
  94. core.register_node("testnodes:nodebox_connected_6side", {
  95. description = S("Connected Nodebox Test Node (6 Side Cable)").."\n"..
  96. S("Connects to 6 neighbors"),
  97. tiles = {"testnodes_nodebox.png^[colorize:#F00:32"},
  98. groups = {connected_nodebox=1, dig_immediate=3},
  99. drawtype = "nodebox",
  100. paramtype = "light",
  101. connects_to = {"group:connected_nodebox"},
  102. connect_sides = {"front", "back", "left", "right", "top", "bottom"},
  103. node_box = nodebox_cable,
  104. })
  105. -- More walls
  106. core.register_node("testnodes:nodebox_connected_facedir", {
  107. description = S("Facedir Connected Nodebox Test Node (4 Side Wall)").."\n"..
  108. S("Connects to neighbors").."\n"..
  109. S("param2 = facedir rotation of textures (not of the nodebox!)"),
  110. tiles = {
  111. "testnodes_1.png",
  112. "testnodes_2.png",
  113. "testnodes_3.png",
  114. "testnodes_4.png",
  115. "testnodes_5.png",
  116. "testnodes_6.png",
  117. },
  118. groups = {connected_nodebox=1, dig_immediate=3},
  119. drawtype = "nodebox",
  120. paramtype = "light",
  121. paramtype2 = "facedir",
  122. connects_to = {"group:connected_nodebox"},
  123. connect_sides = {"front", "back", "left", "right"},
  124. node_box = nodebox_wall_thick,
  125. })
  126. core.register_node("testnodes:nodebox_connected_4dir", {
  127. description = S("4Dir Connected Nodebox Test Node").."\n"..
  128. S("Connects to neighbors").."\n"..
  129. S("param2 = 4dir rotation of textures (not of the nodebox!)"),
  130. tiles = {
  131. "testnodes_1f.png",
  132. "testnodes_2f.png",
  133. "testnodes_3f.png",
  134. "testnodes_4f.png",
  135. "testnodes_5f.png",
  136. "testnodes_6f.png",
  137. },
  138. groups = {connected_nodebox=1, dig_immediate=3},
  139. drawtype = "nodebox",
  140. paramtype = "light",
  141. paramtype2 = "4dir",
  142. connects_to = {"group:connected_nodebox"},
  143. connect_sides = {"front", "back", "left", "right"},
  144. node_box = nodebox_wall_thick,
  145. })
  146. -- Doesn't connect, but lets other nodes connect
  147. core.register_node("testnodes:facedir_to_connect_to", {
  148. description = S("Facedir Node that connected Nodeboxes connect to").."\n"..
  149. S("Neighbors connect only to left (blue 4) and top (yellow 1) face").."\n"..
  150. S("(Currently broken for param2 >= 4, see FIXME in nodedef.cpp)").."\n"..
  151. S("param2 = facedir"),
  152. tiles = {
  153. "testnodes_1.png",
  154. "testnodes_2.png",
  155. "testnodes_3.png",
  156. "testnodes_4.png",
  157. "testnodes_5.png",
  158. "testnodes_6.png",
  159. },
  160. groups = {connected_nodebox=1, dig_immediate=3},
  161. drawtype = "normal",
  162. paramtype2 = "facedir",
  163. connect_sides = {"left", "top"},
  164. })
  165. -- 3D sign and button:
  166. -- These are example nodes for more realistic example uses
  167. -- of wallmounted_rotate_vertical
  168. core.register_node("testnodes:sign3d", {
  169. description = S("Nodebox Sign, Nodebox Type \"fixed\""),
  170. drawtype = "nodebox",
  171. paramtype = "light",
  172. paramtype2 = "wallmounted",
  173. wallmounted_rotate_vertical = true,
  174. sunlight_propagates = true,
  175. walkable = false,
  176. tiles = {
  177. "testnodes_sign3d.png",
  178. },
  179. groups = { dig_immediate = 3 },
  180. node_box = {
  181. type = "fixed",
  182. fixed = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
  183. },
  184. })
  185. core.register_node("testnodes:sign3d_wallmounted", {
  186. description = S("Nodebox Sign, Nodebox Type \"wallmounted\""),
  187. drawtype = "nodebox",
  188. paramtype = "light",
  189. paramtype2 = "wallmounted",
  190. wallmounted_rotate_vertical = true,
  191. sunlight_propagates = true,
  192. walkable = false,
  193. tiles = {
  194. "testnodes_sign3d.png^[colorize:#ff0000:127",
  195. },
  196. groups = { dig_immediate = 3 },
  197. node_box = {
  198. type = "wallmounted",
  199. wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
  200. wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
  201. wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375},
  202. },
  203. })
  204. core.register_node("testnodes:button", {
  205. description = S("Button Nodebox Test Node"),
  206. drawtype = "nodebox",
  207. paramtype = "light",
  208. paramtype2 = "wallmounted",
  209. wallmounted_rotate_vertical = true,
  210. sunlight_propagates = true,
  211. walkable = false,
  212. tiles = {
  213. "testnodes_nodebox.png",
  214. },
  215. groups = { dig_immediate = 3 },
  216. node_box = {
  217. type = "fixed",
  218. fixed = { -4/16, -8/16, -2/16, 4/16, -6/16, 2/16 },
  219. },
  220. })