reed.lua 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. -----------------------------------------------------------------------------------------------
  2. -- Dry Plants - Reed 0.0.5
  3. -----------------------------------------------------------------------------------------------
  4. -- by Mossmanikin
  5. -- Looked at code from: darkage, default, stairs
  6. -- Dependencies: default
  7. -----------------------------------------------------------------------------------------------
  8. -- support for i18n
  9. local S = minetest.get_translator("dryplants")
  10. minetest.register_alias("stairs:stair_wetreed", "dryplants:wetreed_roof")
  11. minetest.register_alias("stairs:slab_wetreed", "dryplants:wetreed_slab")
  12. minetest.register_alias("stairs:stair_reed", "dryplants:reed_roof")
  13. minetest.register_alias("stairs:slab_reed", "dryplants:reed_slab")
  14. -----------------------------------------------------------------------------------------------
  15. -- Wet Reed
  16. -----------------------------------------------------------------------------------------------
  17. minetest.register_node("dryplants:wetreed", {
  18. description = S("Wet Reed"),
  19. paramtype = "light",
  20. paramtype2 = "facedir",
  21. tiles = {"dryplants_reed_wet.png"},
  22. groups = {snappy=3, flammable=2},
  23. sounds = default.node_sound_leaves_defaults(),
  24. })
  25. -----------------------------------------------------------------------------------------------
  26. -- Wet Reed Slab
  27. -----------------------------------------------------------------------------------------------
  28. minetest.register_node("dryplants:wetreed_slab", {
  29. description = S("Wet Reed Slab"),
  30. drawtype = "nodebox",
  31. paramtype = "light",
  32. paramtype2 = "facedir",
  33. tiles = {"dryplants_reed_wet.png"},
  34. node_box = {
  35. type = "fixed",
  36. fixed = {-1/2, -1/2, -1/2, 1/2, 0, 1/2},
  37. },
  38. selection_box = {
  39. type = "fixed",
  40. fixed = {-1/2, -1/2, -1/2, 1/2, 0, 1/2},
  41. },
  42. groups = {snappy=3, flammable=2},
  43. sounds = default.node_sound_leaves_defaults(),
  44. })
  45. -----------------------------------------------------------------------------------------------
  46. -- Wet Reed Roof
  47. -----------------------------------------------------------------------------------------------
  48. minetest.register_node("dryplants:wetreed_roof", {
  49. description = S("Wet Reed Roof"),
  50. drawtype = "nodebox",
  51. paramtype = "light",
  52. paramtype2 = "facedir",
  53. tiles = {"dryplants_reed_wet.png"},
  54. node_box = {
  55. type = "fixed",
  56. -- { left , bottom , front , right , top , back }
  57. fixed = {
  58. {-1/2, 0, 0, 1/2, 1/2, 1/2},
  59. {-1/2, -1/2, -1/2, 1/2, 0, 0},
  60. }
  61. },
  62. selection_box = {
  63. type = "fixed",
  64. fixed = {
  65. {-1/2, 0, 0, 1/2, 1/2, 1/2},
  66. {-1/2, -1/2, -1/2, 1/2, 0, 0},
  67. }
  68. },
  69. groups = {snappy=3, flammable=2},
  70. sounds = default.node_sound_leaves_defaults(),
  71. })
  72. if AUTO_ROOF_CORNER == true then
  73. local CoRNeR = {
  74. -- MaTeRiaL
  75. {"wetreed"},
  76. {"reed"}
  77. }
  78. for i in pairs(CoRNeR) do
  79. local MaTeRiaL = CoRNeR[i][1]
  80. local roof = "dryplants:"..MaTeRiaL.."_roof"
  81. local corner = "dryplants:"..MaTeRiaL.."_roof_corner"
  82. local corner_2 = "dryplants:"..MaTeRiaL.."_roof_corner_2"
  83. minetest.register_abm({
  84. nodenames = {roof},
  85. interval = 1,
  86. chance = 1,
  87. action = function(pos)
  88. local node_east = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z })
  89. local node_west = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z })
  90. local node_north = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1})
  91. local node_south = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
  92. -- corner 1
  93. if ((node_west.name == roof and node_west.param2 == 0)
  94. or (node_west.name == corner and node_west.param2 == 1))
  95. and ((node_north.name == roof and node_north.param2 == 3)
  96. or (node_north.name == corner and node_north.param2 == 3))
  97. then
  98. minetest.swap_node(pos, {name=corner, param2=0})
  99. end
  100. if ((node_north.name == roof and node_north.param2 == 1)
  101. or (node_north.name == corner and node_north.param2 == 2))
  102. and ((node_east.name == roof and node_east.param2 == 0)
  103. or (node_east.name == corner and node_east.param2 == 0))
  104. then
  105. minetest.swap_node(pos, {name=corner, param2=1})
  106. end
  107. if ((node_east.name == roof and node_east.param2 == 2)
  108. or (node_east.name == corner and node_east.param2 == 3))
  109. and ((node_south.name == roof and node_south.param2 == 1)
  110. or (node_south.name == corner and node_south.param2 == 1))
  111. then
  112. minetest.swap_node(pos, {name=corner, param2=2})
  113. end
  114. if ((node_south.name == roof and node_south.param2 == 3)
  115. or (node_south.name == corner and node_south.param2 == 0))
  116. and ((node_west.name == roof and node_west.param2 == 2)
  117. or (node_west.name == corner and node_west.param2 == 2))
  118. then
  119. minetest.swap_node(pos, {name=corner, param2=3})
  120. end
  121. -- corner 2
  122. if ((node_west.name == roof and node_west.param2 == 2)
  123. or (node_west.name == corner_2 and node_west.param2 == 1))
  124. and ((node_north.name == roof and node_north.param2 == 1)
  125. or (node_north.name == corner_2 and node_north.param2 == 3))
  126. then
  127. minetest.swap_node(pos, {name=corner_2, param2=0})
  128. end
  129. if ((node_north.name == roof and node_north.param2 == 3)
  130. or (node_north.name == corner_2 and node_north.param2 == 2))
  131. and ((node_east.name == roof and node_east.param2 == 2)
  132. or (node_east.name == corner_2 and node_east.param2 == 0))
  133. then
  134. minetest.swap_node(pos, {name=corner_2, param2=1})
  135. end
  136. if ((node_east.name == roof and node_east.param2 == 0)
  137. or (node_east.name == corner_2 and node_east.param2 == 3))
  138. and ((node_south.name == roof and node_south.param2 == 3)
  139. or (node_south.name == corner_2 and node_south.param2 == 1))
  140. then
  141. minetest.swap_node(pos, {name=corner_2, param2=2})
  142. end
  143. if ((node_south.name == roof and node_south.param2 == 1)
  144. or (node_south.name == corner_2 and node_south.param2 == 0))
  145. and ((node_west.name == roof and node_west.param2 == 0)
  146. or (node_west.name == corner_2 and node_west.param2 == 2))
  147. then
  148. minetest.swap_node(pos, {name=corner_2, param2=3})
  149. end
  150. end,
  151. })
  152. end
  153. end
  154. -----------------------------------------------------------------------------------------------
  155. -- Wet Reed Roof Corner
  156. -----------------------------------------------------------------------------------------------
  157. minetest.register_node("dryplants:wetreed_roof_corner", {
  158. description = S("Wet Reed Roof Corner"),
  159. drawtype = "nodebox",
  160. paramtype = "light",
  161. paramtype2 = "facedir",
  162. tiles = {"dryplants_reed_wet.png"},
  163. node_box = {
  164. type = "fixed",
  165. -- { left , bottom , front , right , top , back }
  166. fixed = {
  167. {-1/2, 0, 0, 0, 1/2, 1/2},
  168. {0, -1/2, 0, 1/2, 0, 1/2},
  169. {-1/2, -1/2, -1/2, 0, 0, 0},
  170. }
  171. },
  172. selection_box = {
  173. type = "fixed",
  174. fixed = {
  175. {-1/2, 0, 0, 0, 1/2, 1/2},
  176. {0, -1/2, 0, 1/2, 0, 1/2},
  177. {-1/2, -1/2, -1/2, 0, 0, 0},
  178. }
  179. },
  180. groups = {snappy=3, flammable=2},
  181. sounds = default.node_sound_leaves_defaults(),
  182. })
  183. -----------------------------------------------------------------------------------------------
  184. -- Wet Reed Roof Corner 2
  185. -----------------------------------------------------------------------------------------------
  186. minetest.register_node("dryplants:wetreed_roof_corner_2", {
  187. description = S("Wet Reed Roof Corner 2"),
  188. drawtype = "nodebox",
  189. paramtype = "light",
  190. paramtype2 = "facedir",
  191. tiles = {"dryplants_reed_wet.png"},
  192. node_box = {
  193. type = "fixed",
  194. -- { left , bottom , front , right , top , back }
  195. fixed = {
  196. {-1/2, -1/2, 0, 0, 0, 1/2},
  197. {0, 0, 0, 1/2, 1/2, 1/2},
  198. {-1/2, 0, -1/2, 0, 1/2, 0},
  199. }
  200. },
  201. selection_box = {
  202. type = "fixed",
  203. fixed = {
  204. {-1/2, -1/2, 0, 0, 0, 1/2},
  205. {0, 0, 0, 1/2, 1/2, 1/2},
  206. {-1/2, 0, -1/2, 0, 1/2, 0},
  207. }
  208. },
  209. groups = {snappy=3, flammable=2},
  210. sounds = default.node_sound_leaves_defaults(),
  211. })
  212. -----------------------------------------------------------------------------------------------
  213. -- Wet Reed becomes (dry) Reed over time
  214. -----------------------------------------------------------------------------------------------
  215. if REED_WILL_DRY == true then
  216. local DRyiNG = {
  217. -- WeT DRy
  218. {"dryplants:wetreed", "dryplants:reed"},
  219. {"dryplants:wetreed_slab", "dryplants:reed_slab"},
  220. {"dryplants:wetreed_roof", "dryplants:reed_roof"},
  221. {"dryplants:wetreed_roof_corner", "dryplants:reed_roof_corner"},
  222. {"dryplants:wetreed_roof_corner_2", "dryplants:reed_roof_corner_2"}
  223. }
  224. for i in pairs(DRyiNG) do
  225. local WeT = DRyiNG[i][1]
  226. local DRy = DRyiNG[i][2]
  227. minetest.register_abm({
  228. nodenames = {WeT},
  229. interval = REED_DRYING_TIME, --1200, -- 20 minutes: a minetest-day/night-cycle
  230. chance = 1,
  231. action = function(pos)
  232. local direction = minetest.get_node(pos).param2
  233. minetest.swap_node(pos, {name=DRy, param2=direction})
  234. end,
  235. })
  236. end
  237. end
  238. -----------------------------------------------------------------------------------------------
  239. -- Reed
  240. -----------------------------------------------------------------------------------------------
  241. minetest.register_node("dryplants:reed", {
  242. description = S("Reed"),
  243. paramtype = "light",
  244. paramtype2 = "facedir",
  245. tiles = {"dryplants_reed.png"},
  246. groups = {snappy=3, flammable=2},
  247. sounds = default.node_sound_leaves_defaults(),
  248. })
  249. -----------------------------------------------------------------------------------------------
  250. -- Reed Slab
  251. -----------------------------------------------------------------------------------------------
  252. minetest.register_node("dryplants:reed_slab", {
  253. description = S("Reed Slab"),
  254. drawtype = "nodebox",
  255. paramtype = "light",
  256. paramtype2 = "facedir",
  257. tiles = {"dryplants_reed.png"},
  258. node_box = {
  259. type = "fixed",
  260. fixed = {-1/2, -1/2, -1/2, 1/2, 0, 1/2},
  261. },
  262. selection_box = {
  263. type = "fixed",
  264. fixed = {-1/2, -1/2, -1/2, 1/2, 0, 1/2},
  265. },
  266. groups = {snappy=3, flammable=2},
  267. sounds = default.node_sound_leaves_defaults(),
  268. })
  269. -----------------------------------------------------------------------------------------------
  270. -- Reed Roof
  271. -----------------------------------------------------------------------------------------------
  272. minetest.register_node("dryplants:reed_roof", {
  273. description = S("Reed Roof"),
  274. drawtype = "nodebox",
  275. paramtype = "light",
  276. paramtype2 = "facedir",
  277. tiles = {"dryplants_reed.png"},
  278. node_box = {
  279. type = "fixed",
  280. -- { left , bottom , front , right , top , back }
  281. fixed = {
  282. {-1/2, 0, 0, 1/2, 1/2, 1/2},
  283. {-1/2, -1/2, -1/2, 1/2, 0, 0},
  284. }
  285. },
  286. selection_box = {
  287. type = "fixed",
  288. fixed = {
  289. {-1/2, 0, 0, 1/2, 1/2, 1/2},
  290. {-1/2, -1/2, -1/2, 1/2, 0, 0},
  291. }
  292. },
  293. groups = {snappy=3, flammable=2},
  294. sounds = default.node_sound_leaves_defaults(),
  295. })
  296. -----------------------------------------------------------------------------------------------
  297. -- Reed Roof Corner
  298. -----------------------------------------------------------------------------------------------
  299. minetest.register_node("dryplants:reed_roof_corner", {
  300. description = S("Reed Roof Corner"),
  301. drawtype = "nodebox",
  302. paramtype = "light",
  303. paramtype2 = "facedir",
  304. tiles = {"dryplants_reed.png"},
  305. node_box = {
  306. type = "fixed",
  307. -- { left , bottom , front , right , top , back }
  308. fixed = {
  309. {-1/2, 0, 0, 0, 1/2, 1/2},
  310. {0, -1/2, 0, 1/2, 0, 1/2},
  311. {-1/2, -1/2, -1/2, 0, 0, 0},
  312. }
  313. },
  314. selection_box = {
  315. type = "fixed",
  316. fixed = {
  317. {-1/2, 0, 0, 0, 1/2, 1/2},
  318. {0, -1/2, 0, 1/2, 0, 1/2},
  319. {-1/2, -1/2, -1/2, 0, 0, 0},
  320. }
  321. },
  322. groups = {snappy=3, flammable=2},
  323. sounds = default.node_sound_leaves_defaults(),
  324. })
  325. -----------------------------------------------------------------------------------------------
  326. -- Reed Roof Corner 2
  327. -----------------------------------------------------------------------------------------------
  328. minetest.register_node("dryplants:reed_roof_corner_2", {
  329. description = S("Reed Roof Corner 2"),
  330. drawtype = "nodebox",
  331. paramtype = "light",
  332. paramtype2 = "facedir",
  333. tiles = {"dryplants_reed.png"},
  334. node_box = {
  335. type = "fixed",
  336. -- { left , bottom , front , right , top , back }
  337. fixed = {
  338. {-1/2, -1/2, 0, 0, 0, 1/2},
  339. {0, 0, 0, 1/2, 1/2, 1/2},
  340. {-1/2, 0, -1/2, 0, 1/2, 0},
  341. }
  342. },
  343. selection_box = {
  344. type = "fixed",
  345. fixed = {
  346. {-1/2, -1/2, 0, 0, 0, 1/2},
  347. {0, 0, 0, 1/2, 1/2, 1/2},
  348. {-1/2, 0, -1/2, 0, 1/2, 0},
  349. }
  350. },
  351. groups = {snappy=3, flammable=2},
  352. sounds = default.node_sound_leaves_defaults(),
  353. })