init.lua 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. -- This file adds fences of various types
  2. local S = minetest.get_translator("homedecor_fences")
  3. local materials = {
  4. { S("brass"), "brass" },
  5. { S("wrought iron"), "wrought_iron" },
  6. }
  7. for _, m in ipairs(materials) do
  8. local desc, name = unpack(m)
  9. homedecor.register("fence_"..name, {
  10. description = S("Fence/railing (@1)", desc),
  11. drawtype = "fencelike",
  12. tiles = {"homedecor_generic_metal_"..name..".png"},
  13. inventory_image = "homedecor_fence_"..name..".png",
  14. selection_box = homedecor.nodebox.bar_y(1/7),
  15. groups = {snappy=3},
  16. sounds = default.node_sound_wood_defaults(),
  17. })
  18. end
  19. -- other types of fences
  20. homedecor.register("fence_picket", {
  21. description = S("Unpainted Picket Fence"),
  22. tiles = {
  23. "homedecor_blanktile.png",
  24. "homedecor_blanktile.png",
  25. "homedecor_fence_picket.png",
  26. "homedecor_fence_picket.png",
  27. "homedecor_fence_picket_backside.png",
  28. "homedecor_fence_picket.png"
  29. },
  30. groups = {snappy=3},
  31. sounds = default.node_sound_wood_defaults(),
  32. selection_box = homedecor.nodebox.slab_z(-0.1),
  33. node_box = homedecor.nodebox.slab_z(-0.002),
  34. })
  35. homedecor.register("fence_picket_corner", {
  36. description = S("Unpainted Picket Fence Corner"),
  37. tiles = {
  38. "homedecor_blanktile.png",
  39. "homedecor_blanktile.png",
  40. "homedecor_fence_picket.png",
  41. "homedecor_fence_picket_backside.png",
  42. "homedecor_fence_picket_backside.png",
  43. "homedecor_fence_picket.png",
  44. },
  45. groups = {snappy=3},
  46. sounds = default.node_sound_wood_defaults(),
  47. selection_box = homedecor.nodebox.corner_xz(0.1, -0.1),
  48. node_box = homedecor.nodebox.corner_xz(0.002, -0.002),
  49. })
  50. homedecor.register("fence_picket_white", {
  51. description = S("White Picket Fence"),
  52. tiles = {
  53. "homedecor_blanktile.png",
  54. "homedecor_blanktile.png",
  55. "homedecor_fence_picket_white.png",
  56. "homedecor_fence_picket_white.png",
  57. "homedecor_fence_picket_white_backside.png",
  58. "homedecor_fence_picket_white.png"
  59. },
  60. groups = {snappy=3},
  61. sounds = default.node_sound_wood_defaults(),
  62. selection_box = homedecor.nodebox.slab_z(-0.1),
  63. node_box = homedecor.nodebox.slab_z(-0.002),
  64. })
  65. homedecor.register("fence_picket_corner_white", {
  66. description = S("White Picket Fence Corner"),
  67. tiles = {
  68. "homedecor_blanktile.png",
  69. "homedecor_blanktile.png",
  70. "homedecor_fence_picket_white.png",
  71. "homedecor_fence_picket_white_backside.png",
  72. "homedecor_fence_picket_white_backside.png",
  73. "homedecor_fence_picket_white.png",
  74. },
  75. groups = {snappy=3},
  76. sounds = default.node_sound_wood_defaults(),
  77. selection_box = homedecor.nodebox.corner_xz(0.1, -0.1),
  78. node_box = homedecor.nodebox.corner_xz(0.002, -0.002),
  79. })
  80. homedecor.register("fence_privacy", {
  81. description = S("Wooden Privacy Fence"),
  82. tiles = {
  83. "homedecor_fence_privacy_tb.png",
  84. "homedecor_fence_privacy_tb.png",
  85. "homedecor_fence_privacy_sides.png",
  86. "homedecor_fence_privacy_sides.png",
  87. "homedecor_fence_privacy_backside.png",
  88. "homedecor_fence_privacy_front.png"
  89. },
  90. groups = {snappy=3},
  91. sounds = default.node_sound_wood_defaults(),
  92. selection_box = homedecor.nodebox.slab_z(-3/16),
  93. node_box = {
  94. type = "fixed",
  95. fixed = {
  96. { -8/16, -8/16, 5/16, -5/16, 8/16, 7/16 }, -- left part
  97. { -4/16, -8/16, 5/16, 3/16, 8/16, 7/16 }, -- middle part
  98. { 4/16, -8/16, 5/16, 8/16, 8/16, 7/16 }, -- right part
  99. { -8/16, -2/16, 7/16, 8/16, 2/16, 8/16 }, -- connecting rung
  100. }
  101. },
  102. })
  103. homedecor.register("fence_privacy_corner", {
  104. description = S("Wooden Privacy Fence Corner"),
  105. tiles = {
  106. "homedecor_fence_privacy_corner_tb.png",
  107. "homedecor_fence_privacy_corner_tb.png^[transformFY",
  108. "homedecor_fence_privacy_corner_right.png",
  109. "homedecor_fence_privacy_backside2.png",
  110. "homedecor_fence_privacy_backside.png",
  111. "homedecor_fence_privacy_corner_front.png"
  112. },
  113. groups = {snappy=3},
  114. sounds = default.node_sound_wood_defaults(),
  115. selection_box = {
  116. type = "fixed",
  117. fixed = {
  118. homedecor.box.slab_z(-3/16),
  119. { -0.5, -0.5, -0.5, -5/16, 0.5, 5/16 },
  120. }
  121. },
  122. node_box = {
  123. type = "fixed",
  124. fixed = {
  125. { -7/16, -8/16, 5/16, -5/16, 8/16, 7/16 }, -- left part
  126. { -4/16, -8/16, 5/16, 3/16, 8/16, 7/16 }, -- middle part
  127. { 4/16, -8/16, 5/16, 8/16, 8/16, 7/16 }, -- right part
  128. { -8/16, -2/16, 7/16, 8/16, 2/16, 8/16 }, -- back-side connecting rung
  129. { -7/16, -8/16, 4/16, -5/16, 8/16, 7/16 }, -- back-most part
  130. { -7/16, -8/16, -4/16, -5/16, 8/16, 3/16 }, -- middle part
  131. { -7/16, -8/16, -8/16, -5/16, 8/16, -5/16 }, -- front-most part
  132. { -8/16, -2/16, -8/16, -7/16, 2/16, 7/16 }, -- left-side connecting rung
  133. }
  134. },
  135. })
  136. homedecor.register("fence_barbed_wire", {
  137. description = S("Barbed Wire Fence"),
  138. mesh = "homedecor_fence_barbed_wire.obj",
  139. tiles = {"homedecor_fence_barbed_wire.png"},
  140. groups = {snappy=3},
  141. sounds = default.node_sound_wood_defaults(),
  142. selection_box = homedecor.nodebox.slab_z(-0.125),
  143. collision_box = homedecor.nodebox.slab_z(-0.125),
  144. })
  145. homedecor.register("fence_barbed_wire_corner", {
  146. description = S("Barbed Wire Fence Corner"),
  147. mesh = "homedecor_fence_barbed_wire_corner.obj",
  148. tiles = { "homedecor_fence_barbed_wire.png" },
  149. groups = {snappy=3},
  150. sounds = default.node_sound_wood_defaults(),
  151. selection_box = homedecor.nodebox.corner_xz(0.125, -0.125),
  152. collision_box = homedecor.nodebox.corner_xz(0.125, -0.125),
  153. })
  154. homedecor.register("fence_chainlink", {
  155. description = S("Chainlink Fence"),
  156. mesh="homedecor_fence_chainlink.obj",
  157. tiles = {
  158. "homedecor_fence_chainlink_tb.png",
  159. "homedecor_fence_chainlink_tb.png",
  160. "homedecor_fence_chainlink_sides.png",
  161. "homedecor_fence_chainlink_sides.png",
  162. "homedecor_fence_chainlink_fb.png",
  163. "homedecor_fence_chainlink_fb.png",
  164. },
  165. groups = {snappy=3},
  166. sounds = default.node_sound_wood_defaults(),
  167. selection_box = homedecor.nodebox.slab_z(-0.125),
  168. collision_box = homedecor.nodebox.slab_z(-0.125),
  169. })
  170. homedecor.register("fence_chainlink_corner", {
  171. description = S("Chainlink Fence Corner"),
  172. mesh = "homedecor_fence_chainlink_corner.obj",
  173. tiles = {
  174. "homedecor_fence_chainlink_corner_top.png",
  175. "homedecor_fence_chainlink_corner_top.png",
  176. "homedecor_fence_chainlink_corner_front.png",
  177. "homedecor_fence_chainlink_corner_front.png",
  178. "homedecor_fence_chainlink_corner_front.png",
  179. "homedecor_fence_chainlink_corner_front.png",
  180. },
  181. groups = {snappy=3},
  182. sounds = default.node_sound_wood_defaults(),
  183. selection_box = homedecor.nodebox.corner_xz(0.125, -0.125),
  184. collision_box = homedecor.nodebox.corner_xz(0.125, -0.125),
  185. })
  186. homedecor.register("fence_wrought_iron_2", {
  187. description = S("Wrought Iron fence (type 2)"),
  188. tiles = {
  189. "homedecor_fence_wrought_iron_2_tb.png",
  190. "homedecor_fence_wrought_iron_2_tb.png",
  191. "homedecor_fence_wrought_iron_2_sides.png",
  192. "homedecor_fence_wrought_iron_2_sides.png",
  193. "homedecor_fence_wrought_iron_2_fb.png",
  194. "homedecor_fence_wrought_iron_2_fb.png"
  195. },
  196. groups = {snappy=3},
  197. sounds = default.node_sound_wood_defaults(),
  198. selection_box = homedecor.nodebox.slab_z(-0.08),
  199. node_box = {
  200. type = "fixed",
  201. fixed = {
  202. { -8/16, -8/16, 14/32, -7.75/16, 8/16, 16/32 }, -- left post
  203. { 7.75/16, -8/16, 14/32, 8/16, 8/16, 16/32 }, -- right post
  204. { -8/16, 7.75/16, 14/32, 8/16, 8/16, 16/32 }, -- top piece
  205. { -8/16, -0.015625, 14.75/32, 8/16, 0.015625, 15.25/32 }, -- cross piece
  206. { -0.015625, -8/16, 14.75/32, 0.015625, 8/16, 15.25/32 }, -- cross piece
  207. { -8/16, -8/16, 14/32, 8/16, -7.75/16, 16/32 }, -- bottom piece
  208. { -8/16, -8/16, 15/32, 8/16, 8/16, 15/32 } -- the grid itself
  209. }
  210. },
  211. })
  212. homedecor.register("fence_wrought_iron_2_corner", {
  213. description = S("Wrought Iron fence (type 2) Corner"),
  214. tiles = {
  215. "homedecor_fence_corner_wrought_iron_2_tb.png",
  216. "homedecor_fence_corner_wrought_iron_2_tb.png",
  217. "homedecor_fence_corner_wrought_iron_2_sides.png^[transformFX",
  218. "homedecor_fence_corner_wrought_iron_2_sides.png",
  219. "homedecor_fence_corner_wrought_iron_2_sides.png^[transformFX",
  220. "homedecor_fence_corner_wrought_iron_2_sides.png"
  221. },
  222. groups = {snappy=3},
  223. sounds = default.node_sound_wood_defaults(),
  224. selection_box = homedecor.nodebox.corner_xz(0.08, -0.08),
  225. node_box = {
  226. type = "fixed",
  227. fixed = {
  228. { -0.5, -0.5, 0.453125, -0.453125, 0.5, 0.5 }, -- corner edge
  229. { -7.5/16, 7.75/16, 14/32, 8/16, 8/16, 16/32 }, -- top piece
  230. { -7.5/16, -8/16, 14/32, 8/16, -7.75/16, 16/32 }, -- bottom piece
  231. { -16/32, 7.75/16, -8/16, -14/32, 8/16, 8/16 }, -- top piece, side
  232. { -16/32, -8/16, -8/16, -14/32, -7.75/16, 8/16 }, -- bottom piece, side
  233. { -7.5/16, -8/16, 7.5/16, 8/16, 8/16, 7.5/16 }, -- the grid itself
  234. { -7.5/16, -8/16, -8/16, -7.5/16, 8/16, 7.5/16 }, -- the grid itself, side
  235. { -15.5/32, -0.5, -0.5, -14.5/32, 0.5, -0.484375 }, -- left post side
  236. { 7.75/16, -8/16, 14.5/32, 8/16, 8/16, 15.5/32 }, -- right post
  237. { -8/16, -0.015625, 14.75/32, 8/16, 0.015625, 15.25/32 }, -- cross piece
  238. { -0.015625, -8/16, 14.75/32, 0.015625, 8/16, 15.25/32 }, -- cross piece
  239. { -15.25/32, -0.5, -0.015625, -14.75/32, 0.5, 0.015625 }, -- cross piece side
  240. { -15.25/32, -0.015625, -0.5, -14.75/32, 0.015625, 0.5 } -- cross piece side
  241. }
  242. },
  243. })
  244. -- insert the old wood signs-on-metal-fences into signs_lib's conversion LBM
  245. if minetest.get_modpath("signs_lib") then
  246. -- FIXME: export a function in signs_lib API to allow signs_lib to be read only in .luacheckrc
  247. table.insert(signs_lib.old_fenceposts_with_signs, "homedecor:fence_brass_with_sign")
  248. signs_lib.old_fenceposts["homedecor:fence_brass_with_sign"] = "homedecor:fence_brass"
  249. signs_lib.old_fenceposts_replacement_signs["homedecor:fence_brass_with_sign"] = "default:sign_wall_wood_onpole"
  250. table.insert(signs_lib.old_fenceposts_with_signs, "homedecor:fence_wrought_iron_with_sign")
  251. signs_lib.old_fenceposts["homedecor:fence_wrought_iron_with_sign"] = "homedecor:fence_wrought_iron"
  252. signs_lib.old_fenceposts_replacement_signs["homedecor:fence_wrought_iron_with_sign"] = "default:sign_wall_wood_onpole"
  253. end
  254. -- crafting
  255. -- Brass/wrought iron fences
  256. minetest.register_craft( {
  257. output = "homedecor:fence_brass 6",
  258. recipe = {
  259. { "basic_materials:brass_ingot", "basic_materials:brass_ingot", "basic_materials:brass_ingot" },
  260. { "basic_materials:brass_ingot", "basic_materials:brass_ingot", "basic_materials:brass_ingot" },
  261. },
  262. })
  263. minetest.register_craft( {
  264. output = "homedecor:fence_wrought_iron 6",
  265. recipe = {
  266. { "default:iron_lump","default:iron_lump","default:iron_lump" },
  267. { "default:iron_lump","default:iron_lump","default:iron_lump" },
  268. },
  269. })
  270. -- other types of fences
  271. minetest.register_craft( {
  272. output = "homedecor:fence_wrought_iron_2 4",
  273. recipe = {
  274. { "homedecor:pole_wrought_iron", "default:iron_lump" },
  275. { "homedecor:pole_wrought_iron", "default:iron_lump" },
  276. },
  277. })
  278. minetest.register_craft( {
  279. type = "shapeless",
  280. output = "homedecor:fence_wrought_iron_2_corner",
  281. recipe = {
  282. "homedecor:fence_wrought_iron_2",
  283. "homedecor:fence_wrought_iron_2"
  284. },
  285. })
  286. minetest.register_craft( {
  287. type = "shapeless",
  288. output = "homedecor:fence_wrought_iron_2 2",
  289. recipe = {
  290. "homedecor:fence_wrought_iron_2_corner",
  291. },
  292. })
  293. --
  294. minetest.register_craft( {
  295. output = "homedecor:fence_picket 6",
  296. recipe = {
  297. { "group:stick", "group:stick", "group:stick" },
  298. { "group:stick", "", "group:stick" },
  299. { "group:stick", "group:stick", "group:stick" }
  300. },
  301. })
  302. minetest.register_craft( {
  303. type = "shapeless",
  304. output = "homedecor:fence_picket_corner",
  305. recipe = {
  306. "homedecor:fence_picket",
  307. "homedecor:fence_picket"
  308. },
  309. })
  310. minetest.register_craft( {
  311. type = "shapeless",
  312. output = "homedecor:fence_picket 2",
  313. recipe = {
  314. "homedecor:fence_picket_corner"
  315. },
  316. })
  317. --
  318. minetest.register_craft( {
  319. output = "homedecor:fence_picket_white 6",
  320. recipe = {
  321. { "group:stick", "group:stick", "group:stick" },
  322. { "group:stick", "dye:white", "group:stick" },
  323. { "group:stick", "group:stick", "group:stick" }
  324. },
  325. })
  326. minetest.register_craft( {
  327. type = "shapeless",
  328. output = "homedecor:fence_picket_corner_white",
  329. recipe = {
  330. "homedecor:fence_picket_white",
  331. "homedecor:fence_picket_white"
  332. },
  333. })
  334. minetest.register_craft( {
  335. type = "shapeless",
  336. output = "homedecor:fence_picket_white 2",
  337. recipe = {
  338. "homedecor:fence_picket_corner_white"
  339. },
  340. })
  341. --
  342. minetest.register_craft( {
  343. output = "homedecor:fence_privacy 6",
  344. recipe = {
  345. { "group:wood", "group:stick", "group:wood" },
  346. { "group:wood", "", "group:wood" },
  347. { "group:wood", "group:stick", "group:wood" }
  348. },
  349. })
  350. minetest.register_craft( {
  351. type = "shapeless",
  352. output = "homedecor:fence_privacy_corner",
  353. recipe = {
  354. "homedecor:fence_privacy",
  355. "homedecor:fence_privacy"
  356. },
  357. })
  358. minetest.register_craft( {
  359. type = "shapeless",
  360. output = "homedecor:fence_privacy 2",
  361. recipe = {
  362. "homedecor:fence_privacy_corner"
  363. },
  364. })
  365. --
  366. minetest.register_craft( {
  367. output = "homedecor:fence_barbed_wire 6",
  368. recipe = {
  369. { "group:stick", "basic_materials:steel_wire", "group:stick" },
  370. { "group:stick", "", "group:stick" },
  371. { "group:stick", "basic_materials:steel_wire", "group:stick" }
  372. },
  373. })
  374. minetest.register_craft( {
  375. type = "shapeless",
  376. output = "homedecor:fence_barbed_wire_corner",
  377. recipe = { "homedecor:fence_barbed_wire", "homedecor:fence_barbed_wire" },
  378. })
  379. minetest.register_craft( {
  380. type = "shapeless",
  381. output = "homedecor:fence_barbed_wire 2",
  382. recipe = { "homedecor:fence_barbed_wire_corner" },
  383. })
  384. --
  385. minetest.register_craft( {
  386. output = "homedecor:fence_chainlink 9",
  387. recipe = {
  388. { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
  389. { "basic_materials:steel_wire", "basic_materials:steel_wire", "default:steel_ingot" },
  390. { "basic_materials:steel_wire", "basic_materials:steel_wire", "default:steel_ingot" }
  391. },
  392. })
  393. minetest.register_craft( {
  394. type = "shapeless",
  395. output = "homedecor:fence_chainlink_corner",
  396. recipe = { "homedecor:fence_chainlink", "homedecor:fence_chainlink" },
  397. })
  398. minetest.register_craft( {
  399. type = "shapeless",
  400. output = "homedecor:fence_chainlink 2",
  401. recipe = { "homedecor:fence_chainlink_corner" },
  402. })