gates.lua 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. local MP, S, NS = nil
  2. if (minetest.get_modpath("intllib") == nil) then
  3. S = minetest.get_translator("castle_gates")
  4. else
  5. -- internationalization boilerplate
  6. MP = minetest.get_modpath(minetest.get_current_modname())
  7. S, NS = dofile(MP.."/intllib.lua")
  8. end
  9. minetest.register_alias("castle_gates:gate_edge", "castle_gates:wood_gate_edge")
  10. minetest.register_alias("castle_gates:gate_edge_handle", "castle_gates:wood_gate_edge_handle")
  11. minetest.register_alias("castle_gates:gate_hinge", "castle_gates:wood_gate_hinge")
  12. minetest.register_alias("castle_gates:gate_panel", "castle_gates:wood_gate_panel")
  13. minetest.register_alias("castle_gates:portcullis_bars", "castle_gates:wood_portcullis_bars")
  14. minetest.register_alias("castle_gates:portcullis_bars_bottom", "castle_gates:wood_portcullis_bars_bottom")
  15. local register_gates = function(node_prefix, material_description, material_texture, gate_groups, gate_sounds, portcullis_recipe, panel_recipe)
  16. local portcullis_groups = {castle_gate = 1, flow_through = 1}
  17. local panel_groups = {castle_gate = 1}
  18. for group, val in pairs(gate_groups) do
  19. portcullis_groups[group] = val
  20. panel_groups[group] = val
  21. end
  22. minetest.register_node("castle_gates:"..node_prefix.."_portcullis_bars", {
  23. drawtype = "nodebox",
  24. description = S("@1 Portcullis Bars", material_description),
  25. _doc_items_longdesc = castle_gates.doc.portcullis_bars_longdesc,
  26. _doc_items_usagehelp = castle_gates.doc.portcullis_bars_usagehelp,
  27. groups = portcullis_groups,
  28. tiles = {
  29. "castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
  30. "castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
  31. material_texture.."^[transformR90",
  32. material_texture.."^[transformR90",
  33. "castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
  34. "castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
  35. },
  36. sounds = gate_sounds,
  37. paramtype = "light",
  38. paramtype2 = "facedir",
  39. node_box = {
  40. type = "fixed",
  41. fixed = {
  42. {-0.125, -0.5, -0.5, 0.125, 0.5, -0.25}, -- middle bar
  43. {-0.5, -0.5, -0.5, -0.375, 0.5, -0.25}, -- side bar
  44. {0.375, -0.5, -0.5, 0.5, 0.5, -0.25}, -- side bar
  45. {-0.375, 0.1875, -0.4375, 0.375, 0.3125, -0.3125}, -- crosspiece
  46. {-0.375, -0.3125, -0.4375, 0.375, -0.1875, -0.3125}, -- crosspiece
  47. }
  48. },
  49. on_rightclick = castle_gates.trigger_gate,
  50. })
  51. minetest.register_node("castle_gates:"..node_prefix.."_portcullis_bars_bottom", {
  52. drawtype = "nodebox",
  53. description = S("@1 Portcullis Bottom", material_description),
  54. _doc_items_longdesc = castle_gates.doc.portcullis_bars_bottom_longdesc,
  55. _doc_items_usagehelp = castle_gates.doc.portcullis_bars_bottom_usagehelp,
  56. groups = portcullis_groups,
  57. tiles = {
  58. "castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
  59. "castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
  60. material_texture.."^[transformR90",
  61. material_texture.."^[transformR90",
  62. "castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
  63. "castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
  64. },
  65. sounds = gate_sounds,
  66. paramtype = "light",
  67. paramtype2 = "facedir",
  68. node_box = {
  69. type = "fixed",
  70. fixed = {
  71. {-0.125, -0.5, -0.5, 0.125, 0.5, -0.25}, -- middle bar
  72. {-0.5, -0.5, -0.5, -0.375, 0.5, -0.25}, -- side bar
  73. {0.375, -0.5, -0.5, 0.5, 0.5, -0.25}, -- side bar
  74. {-0.375, 0.1875, -0.4375, 0.375, 0.3125, -0.3125}, -- crosspiece
  75. {-0.375, -0.3125, -0.4375, 0.375, -0.1875, -0.3125}, -- crosspiece
  76. {-0.0625, -0.5, -0.4375, 0.0625, -0.625, -0.3125}, -- peg
  77. {0.4375, -0.5, -0.4375, 0.5, -0.625, -0.3125}, -- peg
  78. {-0.5, -0.5, -0.4375, -0.4375, -0.625, -0.3125}, -- peg
  79. }
  80. },
  81. _gate_edges = {bottom=true},
  82. on_rightclick = castle_gates.trigger_gate,
  83. })
  84. minetest.register_craft({
  85. output = "castle_gates:"..node_prefix.."_portcullis_bars 3",
  86. recipe = portcullis_recipe,
  87. })
  88. minetest.register_craft({
  89. output = "castle_gates:"..node_prefix.."_portcullis_bars",
  90. recipe = {
  91. {"castle_gates:"..node_prefix.."_portcullis_bars_bottom"}
  92. },
  93. })
  94. minetest.register_craft({
  95. output = "castle_gates:"..node_prefix.."_portcullis_bars_bottom",
  96. recipe = {
  97. {"castle_gates:"..node_prefix.."_portcullis_bars"}
  98. },
  99. })
  100. --------------------------------------------------------------------------------------------------------------
  101. minetest.register_craft({
  102. output = "castle_gates:"..node_prefix.."_gate_panel 8",
  103. recipe = panel_recipe,
  104. })
  105. minetest.register_node("castle_gates:"..node_prefix.."_gate_panel", {
  106. drawtype = "nodebox",
  107. description = S("@1 Gate Door", material_description),
  108. _doc_items_longdesc = castle_gates.doc.gate_panel_longdesc,
  109. _doc_items_usagehelp = castle_gates.doc.gate_panel_usagehelp,
  110. groups = panel_groups,
  111. tiles = {
  112. material_texture.."^[transformR90",
  113. material_texture.."^[transformR90",
  114. material_texture.."^[transformR90",
  115. material_texture.."^[transformR90",
  116. material_texture.."^[transformR90",
  117. material_texture.."^[transformR90",
  118. },
  119. sounds = gate_sounds,
  120. paramtype = "light",
  121. paramtype2 = "facedir",
  122. node_box = {
  123. type = "fixed",
  124. fixed = {
  125. {-0.5, -0.5, -0.5, 0.5, 0.5, -0.25},
  126. }
  127. },
  128. on_rightclick = castle_gates.trigger_gate,
  129. })
  130. minetest.register_craft({
  131. output = "castle_gates:"..node_prefix.."_gate_edge",
  132. type = "shapeless",
  133. recipe = {"castle_gates:"..node_prefix.."_gate_panel"},
  134. })
  135. minetest.register_node("castle_gates:"..node_prefix.."_gate_edge", {
  136. drawtype = "nodebox",
  137. description = S("@1 Gate Door Edge", material_description),
  138. _doc_items_longdesc = castle_gates.doc.gate_edge_longdesc,
  139. _doc_items_usagehelp = castle_gates.doc.gate_edge_usagehelp,
  140. groups = panel_groups,
  141. tiles = {
  142. material_texture.."^[transformR90",
  143. material_texture.."^[transformR90",
  144. material_texture.."^[transformR90",
  145. material_texture.."^[transformR90",
  146. material_texture.."^[transformR90^(default_coal_block.png^[mask:castle_door_edge_mask.png^[transformFX)",
  147. material_texture.."^[transformR90^(default_coal_block.png^[mask:castle_door_edge_mask.png)",
  148. },
  149. sounds = gate_sounds,
  150. paramtype = "light",
  151. paramtype2 = "facedir",
  152. node_box = {
  153. type = "fixed",
  154. fixed = {
  155. {-0.5, -0.5, -0.5, 0.5, 0.5, -0.25},
  156. }
  157. },
  158. _gate_edges = {right=true},
  159. on_rightclick = castle_gates.trigger_gate,
  160. })
  161. minetest.register_craft({
  162. output = "castle_gates:"..node_prefix.."_gate_edge_handle",
  163. type = "shapeless",
  164. recipe = {"castle_gates:"..node_prefix.."_gate_edge"},
  165. })
  166. minetest.register_craft({
  167. output = "castle_gates:"..node_prefix.."_gate_panel",
  168. type = "shapeless",
  169. recipe = {"castle_gates:"..node_prefix.."_gate_edge_handle"},
  170. })
  171. minetest.register_node("castle_gates:"..node_prefix.."_gate_edge_handle", {
  172. drawtype = "nodebox",
  173. description = S("@1 Gate Door With Handle", material_description),
  174. _doc_items_longdesc = castle_gates.doc.gate_edge_handle_longdesc,
  175. _doc_items_usagehelp = castle_gates.doc.gate_edge_handle_usagehelp,
  176. groups = panel_groups,
  177. tiles = {
  178. "castle_steel.png^("..material_texture.."^[mask:castle_door_side_mask.png^[transformR90)",
  179. "castle_steel.png^("..material_texture.."^[mask:castle_door_side_mask.png^[transformR270)",
  180. "castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_door_side_mask.png)",
  181. "castle_steel.png^("..material_texture.."^[transformR90^[mask:(castle_door_side_mask.png^[transformFX))",
  182. material_texture.."^[transformR90^(default_coal_block.png^[mask:castle_door_edge_mask.png^[transformFX)^(castle_steel.png^[mask:castle_door_handle_mask.png^[transformFX)",
  183. material_texture.."^[transformR90^(default_coal_block.png^[mask:castle_door_edge_mask.png)^(castle_steel.png^[mask:castle_door_handle_mask.png)",
  184. },
  185. sounds = gate_sounds,
  186. paramtype = "light",
  187. paramtype2 = "facedir",
  188. node_box = {
  189. type = "fixed",
  190. fixed = {
  191. {-0.5, -0.5, -0.5, 0.5, 0.5, -0.25},
  192. {4/16, -4/16, -2/16, 6/16, 4/16, -3/16},
  193. {4/16, -4/16, -9/16, 6/16, 4/16, -10/16},
  194. {4/16, -4/16, -9/16, 6/16, -3/16, -3/16},
  195. {4/16, 4/16, -9/16, 6/16, 3/16, -3/16},
  196. }
  197. },
  198. _gate_edges = {right=true},
  199. on_rightclick = castle_gates.trigger_gate,
  200. })
  201. ------------------------------------------------------------------------------
  202. minetest.register_craft({
  203. output = "castle_gates:"..node_prefix.."_gate_hinge 3",
  204. recipe = {
  205. {"", "castle_gates:"..node_prefix.."_gate_panel", ""},
  206. {"default:steel_ingot", "castle_gates:"..node_prefix.."_gate_panel", ""},
  207. {"", "castle_gates:"..node_prefix.."_gate_panel", ""}
  208. },
  209. })
  210. minetest.register_node("castle_gates:"..node_prefix.."_gate_hinge", {
  211. drawtype = "nodebox",
  212. description = S("@1 Gate Door With Hinge", material_description),
  213. _doc_items_longdesc = castle_gates.doc.gate_hinge_longdesc,
  214. _doc_items_usagehelp = castle_gates.doc.gate_hinge_usagehelp,
  215. groups = panel_groups,
  216. tiles = {
  217. material_texture.."^[transformR90",
  218. },
  219. sounds = gate_sounds,
  220. paramtype = "light",
  221. paramtype2 = "facedir",
  222. node_box = {
  223. type = "fixed",
  224. fixed = {
  225. {-0.5, -0.5, -0.5, 0.5, 0.5, -0.25},
  226. {-10/16, -4/16, -10/16, -6/16, 4/16, -6/16},
  227. }
  228. },
  229. collision_box = {
  230. type = "fixed",
  231. fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, -0.25},
  232. },
  233. _gate_hinge = {axis="top", offset={"front","left"}},
  234. on_rightclick = castle_gates.trigger_gate,
  235. })
  236. end
  237. register_gates("wood", S("Wooden"), "default_wood.png", {choppy = 1, castle_gate=1}, default.node_sound_wood_defaults(),
  238. {
  239. {"group:wood","default:steel_ingot","group:wood" },
  240. {"group:wood","default:steel_ingot","group:wood" },
  241. {"group:wood","default:steel_ingot","group:wood" },
  242. },
  243. {
  244. {"stairs:slab_wood","stairs:slab_wood", ""},
  245. {"stairs:slab_wood","stairs:slab_wood", ""},
  246. }
  247. )
  248. register_gates("steel", S("Steel"), "default_steel_block.png", {cracky = 1, level = 2, castle_gate=1}, default.node_sound_metal_defaults(),
  249. {
  250. {"","default:steel_ingot","" },
  251. {"default:steel_ingot","default:steel_ingot","default:steel_ingot" },
  252. {"","default:steel_ingot","" },
  253. },
  254. {
  255. {"stairs:slab_steelblock","stairs:slab_steelblock", ""},
  256. {"stairs:slab_steelblock","stairs:slab_steelblock", ""},
  257. }
  258. )