generating.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. -- Code by Mossmanikin, Neuromancer, and others
  2. -----------------------------------------------------------------------------------------------
  3. -- TWiGS
  4. -----------------------------------------------------------------------------------------------
  5. abstract_trunks.place_twig = function(pos)
  6. local twig_size = math.random(1,27)
  7. local right_here = {x=pos.x , y=pos.y+1, z=pos.z }
  8. local north = {x=pos.x , y=pos.y+1, z=pos.z+1}
  9. local north_east = {x=pos.x+1, y=pos.y+1, z=pos.z+1}
  10. local east = {x=pos.x+1, y=pos.y+1, z=pos.z }
  11. local south_east = {x=pos.x+1, y=pos.y+1, z=pos.z-1}
  12. local south = {x=pos.x , y=pos.y+1, z=pos.z-1}
  13. local south_west = {x=pos.x-1, y=pos.y+1, z=pos.z-1}
  14. local west = {x=pos.x-1, y=pos.y+1, z=pos.z }
  15. local north_west = {x=pos.x-1, y=pos.y+1, z=pos.z+1}
  16. local node_here = minetest.get_node(right_here)
  17. local node_north = minetest.get_node(north)
  18. local node_n_e = minetest.get_node(north_east)
  19. local node_east = minetest.get_node(east)
  20. local node_s_e = minetest.get_node(south_east)
  21. local node_south = minetest.get_node(south)
  22. local node_s_w = minetest.get_node(south_west)
  23. local node_west = minetest.get_node(west)
  24. local node_n_w = minetest.get_node(north_west)
  25. -- small twigs
  26. if twig_size <= 16 then
  27. minetest.swap_node(right_here, {name="trunks:twig_"..math.random(1,4), param2=math.random(0,3)})
  28. end
  29. -- big twigs
  30. if Big_Twigs == true then
  31. -- big twig 1
  32. if twig_size == 17 then
  33. if not (minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z+1}).name].buildable_to
  34. or minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}).name].buildable_to) then
  35. if minetest.registered_nodes[node_here.name].buildable_to then
  36. minetest.swap_node(right_here, {name="trunks:twig_5"})
  37. end
  38. if minetest.registered_nodes[node_n_e.name].buildable_to then
  39. minetest.swap_node(north_east, {name="trunks:twig_7"})
  40. end
  41. if minetest.registered_nodes[node_east.name].buildable_to then
  42. minetest.swap_node(east, {name="trunks:twig_8"})
  43. end
  44. end
  45. elseif twig_size == 18 then
  46. if not (minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z-1}).name].buildable_to
  47. or minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}).name].buildable_to) then
  48. if minetest.registered_nodes[node_here.name].buildable_to then
  49. minetest.swap_node(right_here, {name="trunks:twig_5", param2=1})
  50. end
  51. if minetest.registered_nodes[node_s_e.name].buildable_to then
  52. minetest.swap_node(south_east, {name="trunks:twig_7", param2=1})
  53. end
  54. if minetest.registered_nodes[node_south.name].buildable_to then
  55. minetest.swap_node(south, {name="trunks:twig_8", param2=1})
  56. end
  57. end
  58. elseif twig_size == 19 then
  59. if not (minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z-1}).name].buildable_to
  60. or minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}).name].buildable_to) then
  61. if minetest.registered_nodes[node_here.name].buildable_to then
  62. minetest.swap_node(right_here, {name="trunks:twig_5", param2=2})
  63. end
  64. if minetest.registered_nodes[node_s_w.name].buildable_to then
  65. minetest.swap_node(south_west, {name="trunks:twig_7", param2=2})
  66. end
  67. if minetest.registered_nodes[node_west.name].buildable_to then
  68. minetest.swap_node(west, {name="trunks:twig_8", param2=2})
  69. end
  70. end
  71. elseif twig_size == 20 then
  72. if not (minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z+1}).name].buildable_to
  73. or minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}).name].buildable_to) then
  74. if minetest.registered_nodes[node_here.name].buildable_to then
  75. minetest.swap_node(right_here, {name="trunks:twig_5", param2=3})
  76. end
  77. if minetest.registered_nodes[node_n_w.name].buildable_to then
  78. minetest.swap_node(north_west, {name="trunks:twig_7", param2=3})
  79. end
  80. if minetest.registered_nodes[node_north.name].buildable_to then
  81. minetest.swap_node(north, {name="trunks:twig_8", param2=3})
  82. end
  83. end
  84. -- big twig 2
  85. elseif twig_size == 21 then
  86. if not (minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}).name].buildable_to
  87. or minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z+1}).name].buildable_to) then
  88. if minetest.registered_nodes[node_here.name].buildable_to then
  89. minetest.swap_node(right_here, {name="trunks:twig_9"})
  90. end
  91. if minetest.registered_nodes[node_north.name].buildable_to then
  92. minetest.swap_node(north, {name="trunks:twig_10"})
  93. end
  94. if minetest.registered_nodes[node_n_e.name].buildable_to then
  95. minetest.swap_node(north_east, {name="trunks:twig_11"})
  96. end
  97. end
  98. elseif twig_size == 22 then
  99. if not (minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}).name].buildable_to
  100. or minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z-1}).name].buildable_to) then
  101. if minetest.registered_nodes[node_here.name].buildable_to then
  102. minetest.swap_node(right_here, {name="trunks:twig_9", param2=1})
  103. end
  104. if minetest.registered_nodes[node_east.name].buildable_to then
  105. minetest.swap_node(east, {name="trunks:twig_10", param2=1})
  106. end
  107. if minetest.registered_nodes[node_s_e.name].buildable_to then
  108. minetest.swap_node(south_east, {name="trunks:twig_11", param2=1})
  109. end
  110. end
  111. elseif twig_size == 23 then
  112. if not (minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}).name].buildable_to
  113. or minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z-1}).name].buildable_to) then
  114. if minetest.registered_nodes[node_here.name].buildable_to then
  115. minetest.swap_node(right_here, {name="trunks:twig_9", param2=2})
  116. end
  117. if minetest.registered_nodes[node_south.name].buildable_to then
  118. minetest.swap_node(south, {name="trunks:twig_10", param2=2})
  119. end
  120. if minetest.registered_nodes[node_s_w.name].buildable_to then
  121. minetest.swap_node(south_west, {name="trunks:twig_11", param2=2})
  122. end
  123. end
  124. elseif twig_size == 24 then
  125. if not (minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}).name].buildable_to
  126. or minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z+1}).name].buildable_to) then
  127. if minetest.registered_nodes[node_here.name].buildable_to then
  128. minetest.swap_node(right_here, {name="trunks:twig_9", param2=3})
  129. end
  130. if minetest.registered_nodes[node_west.name].buildable_to then
  131. minetest.swap_node(west, {name="trunks:twig_10", param2=3})
  132. end
  133. if minetest.registered_nodes[node_n_w.name].buildable_to then
  134. minetest.swap_node(north_west, {name="trunks:twig_11", param2=3})
  135. end
  136. end
  137. elseif twig_size <= 25 then
  138. minetest.swap_node(right_here, {name="trunks:twig_"..math.random(12,13), param2=math.random(0,3)})
  139. end
  140. end
  141. end
  142. if Twigs_on_ground == true then
  143. biome_lib:register_generate_plant({
  144. surface = {"default:dirt_with_grass"},
  145. max_count = Twigs_on_ground_Max_Count,
  146. rarity = Twigs_on_ground_Rarity,
  147. min_elevation = 1,
  148. max_elevation = 40,
  149. near_nodes = {"group:tree","ferns:fern_03","ferns:fern_02","ferns:fern_01"},
  150. near_nodes_size = 3,
  151. near_nodes_vertical = 1,
  152. near_nodes_count = 1,
  153. plantlife_limit = -0.9,
  154. },
  155. abstract_trunks.place_twig
  156. )
  157. end
  158. if Twigs_on_water == true then
  159. biome_lib:register_generate_plant({
  160. surface = {"default:water_source"},
  161. max_count = Twigs_on_water_Max_Count,
  162. rarity = Twigs_on_water_Rarity,
  163. min_elevation = 1,
  164. max_elevation = 40,
  165. near_nodes = {"group:tree"},
  166. near_nodes_size = 3,
  167. near_nodes_vertical = 1,
  168. near_nodes_count = 1,
  169. plantlife_limit = -0.9,
  170. },
  171. abstract_trunks.place_twig
  172. )
  173. end
  174. -----------------------------------------------------------------------------------------------
  175. -- TRuNKS
  176. -----------------------------------------------------------------------------------------------
  177. local TRuNKS = {
  178. -- MoD TRuNK NR
  179. {"default", "tree", 1},
  180. {"default", "jungletree", 2},
  181. {"default", "pine_tree", 12},
  182. {"trees", "tree_conifer", 3},
  183. {"trees", "tree_mangrove", 4},
  184. {"trees", "tree_palm", 5},
  185. {"moretrees", "apple_tree_trunk", 6},
  186. {"moretrees", "beech_trunk", 7},
  187. {"moretrees", "birch_trunk", 8},
  188. {"moretrees", "fir_trunk", 9},
  189. {"moretrees", "oak_trunk", 10},
  190. {"moretrees", "palm_trunk", 11},
  191. {"moretrees", "rubber_tree_trunk", 13},
  192. {"moretrees", "rubber_tree_trunk_empty", 14},
  193. {"moretrees", "sequoia_trunk", 15},
  194. {"moretrees", "spruce_trunk", 16},
  195. {"moretrees", "willow_trunk", 17},
  196. }
  197. if Horizontal_Trunks == true then -- see settings.txt
  198. for i in pairs(TRuNKS) do
  199. local MoD = TRuNKS[i][1]
  200. local TRuNK = TRuNKS[i][2]
  201. local NR = TRuNKS[i][3]
  202. local trunkname = MoD..":"..TRuNK
  203. if minetest.get_modpath(MoD) ~= nil
  204. and NR < 6 -- moretrees trunks allready have facedir
  205. and minetest.registered_nodes[trunkname] then -- the node being called exists.
  206. temptrunk = table.copy(minetest.registered_nodes[trunkname])
  207. temptrunk.paramtype2 = "facedir"
  208. minetest.register_node(":"..trunkname, temptrunk)
  209. end
  210. end
  211. end
  212. abstract_trunks.place_trunk = function(pos)
  213. local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
  214. local north = {x=pos.x, y=pos.y+1, z=pos.z+1}
  215. local north2 = {x=pos.x, y=pos.y+1, z=pos.z+2}
  216. local south = {x=pos.x, y=pos.y+1, z=pos.z-1}
  217. local south2 = {x=pos.x, y=pos.y+1, z=pos.z-2}
  218. local west = {x=pos.x-1, y=pos.y+1, z=pos.z}
  219. local west2 = {x=pos.x-2, y=pos.y+1, z=pos.z}
  220. local east = {x=pos.x+1, y=pos.y+1, z=pos.z}
  221. local east2 = {x=pos.x+2, y=pos.y+1, z=pos.z}
  222. local node_here = minetest.get_node(right_here)
  223. local node_north = minetest.get_node(north)
  224. local node_north2 = minetest.get_node(north2)
  225. local node_south = minetest.get_node(south)
  226. local node_south2 = minetest.get_node(south2)
  227. local node_west = minetest.get_node(west)
  228. local node_west2 = minetest.get_node(west2)
  229. local node_east = minetest.get_node(east)
  230. local node_east2 = minetest.get_node(east2)
  231. if minetest.registered_nodes[node_here.name].buildable_to then -- instead of check_air = true,
  232. for i in pairs(TRuNKS) do
  233. local MoD = TRuNKS[i][1]
  234. local TRuNK = TRuNKS[i][2]
  235. local NR = TRuNKS[i][3]
  236. local chance = math.random(1, 17)
  237. local length = math.random(3,5)
  238. if chance == NR then
  239. local trunk_type = math.random(1,3)
  240. if trunk_type == 1 then
  241. if minetest.get_modpath(MoD) ~= nil then
  242. minetest.swap_node(right_here, {name=MoD..":"..TRuNK})
  243. else
  244. minetest.swap_node(right_here, {name="default:tree"})
  245. end
  246. elseif trunk_type == 2 and Horizontal_Trunks == true then
  247. if minetest.get_modpath(MoD) ~= nil then
  248. if minetest.registered_nodes[node_north.name].buildable_to then
  249. minetest.swap_node(north, {name=MoD..":"..TRuNK, param2=4})
  250. end
  251. if length >= 4 and minetest.registered_nodes[node_north2.name].buildable_to then
  252. minetest.swap_node(north2, {name=MoD..":"..TRuNK, param2=4})
  253. end
  254. minetest.swap_node(right_here, {name=MoD..":"..TRuNK, param2=4})
  255. if minetest.registered_nodes[node_south.name].buildable_to then
  256. minetest.swap_node(south, {name=MoD..":"..TRuNK, param2=4})
  257. end
  258. if length == 5 and minetest.registered_nodes[node_south2.name].buildable_to then
  259. minetest.swap_node(south2, {name=MoD..":"..TRuNK, param2=4})
  260. end
  261. else
  262. if minetest.registered_nodes[node_north.name].buildable_to then
  263. minetest.swap_node(north, {name="default:tree", param2=4})
  264. end
  265. if length >= 4 and minetest.registered_nodes[node_north2.name].buildable_to then
  266. minetest.swap_node(north2, {name="default:tree", param2=4})
  267. end
  268. minetest.swap_node(right_here, {name="default:tree", param2=4})
  269. if minetest.registered_nodes[node_south.name].buildable_to then
  270. minetest.swap_node(south, {name="default:tree", param2=4})
  271. end
  272. if length == 5 and minetest.registered_nodes[node_south2.name].buildable_to then
  273. minetest.swap_node(south2, {name="default:tree", param2=4})
  274. end
  275. end
  276. elseif trunk_type == 3 and Horizontal_Trunks == true then
  277. if minetest.get_modpath(MoD) ~= nil then
  278. if minetest.registered_nodes[node_west.name].buildable_to then
  279. minetest.swap_node(west, {name=MoD..":"..TRuNK, param2=12})
  280. end
  281. if length >= 4 and minetest.registered_nodes[node_west2.name].buildable_to then
  282. minetest.swap_node(west2, {name=MoD..":"..TRuNK, param2=12})
  283. end
  284. minetest.swap_node(right_here, {name=MoD..":"..TRuNK, param2=12})
  285. if minetest.registered_nodes[node_east.name].buildable_to then
  286. minetest.swap_node(east, {name=MoD..":"..TRuNK, param2=12})
  287. end
  288. if length == 5 and minetest.registered_nodes[node_east2.name].buildable_to then
  289. minetest.swap_node(east2, {name=MoD..":"..TRuNK, param2=12})
  290. end
  291. else
  292. if minetest.registered_nodes[node_west.name].buildable_to then
  293. minetest.swap_node(west, {name="default:tree", param2=12})
  294. end
  295. if length >= 4 and minetest.registered_nodes[node_west2.name].buildable_to then
  296. minetest.swap_node(west2, {name="default:tree", param2=12})
  297. end
  298. minetest.swap_node(right_here, {name="default:tree", param2=12})
  299. if minetest.registered_nodes[node_east.name].buildable_to then
  300. minetest.swap_node(east, {name="default:tree", param2=12})
  301. end
  302. if length == 5 and minetest.registered_nodes[node_east2.name].buildable_to then
  303. minetest.swap_node(east2, {name="default:tree", param2=12})
  304. end
  305. end
  306. end
  307. end
  308. end
  309. end
  310. end
  311. biome_lib:register_generate_plant({
  312. surface = {"default:dirt_with_grass"},
  313. max_count = Trunks_Max_Count, -- 320,
  314. rarity = Trunks_Rarity, -- 99,
  315. min_elevation = 1,
  316. max_elevation = 40,
  317. avoid_nodes = {"group:tree"},
  318. avoid_radius = 1,
  319. near_nodes = {"group:tree","ferns:fern_03","ferns:fern_02","ferns:fern_01"},
  320. near_nodes_size = 3,
  321. near_nodes_vertical = 1,
  322. near_nodes_count = 1,
  323. plantlife_limit = -0.9,
  324. },
  325. abstract_trunks.place_trunk
  326. )
  327. -----------------------------------------------------------------------------------------------
  328. -- MoSS & FuNGuS -- on ground
  329. -----------------------------------------------------------------------------------------------
  330. if Moss_on_ground == true then
  331. abstract_trunks.grow_moss_on_ground = function(pos)
  332. local on_ground = {x=pos.x, y=pos.y+1, z=pos.z}
  333. local moss_type = math.random(1,21)
  334. if moss_type == 1 then
  335. minetest.swap_node(on_ground, {name="trunks:moss_fungus", param2=math.random(0,3)})
  336. else
  337. minetest.swap_node(on_ground, {name="trunks:moss", param2=math.random(0,3)})
  338. end
  339. end
  340. biome_lib:register_generate_plant({
  341. surface = {"default:dirt_with_grass"},
  342. max_count = Moss_on_ground_Max_Count,
  343. rarity = Moss_on_ground_Rarity,
  344. min_elevation = 1,
  345. max_elevation = 40,
  346. near_nodes = {
  347. "group:tree",
  348. "ferns:fern_03",
  349. "ferns:fern_02",
  350. "ferns:fern_01"
  351. },
  352. near_nodes_size = 2,
  353. near_nodes_vertical = 1,
  354. near_nodes_count = 1,
  355. plantlife_limit = -0.9,
  356. },
  357. abstract_trunks.grow_moss_on_ground
  358. )
  359. end
  360. -----------------------------------------------------------------------------------------------
  361. -- MoSS & FuNGuS -- on trunks
  362. -----------------------------------------------------------------------------------------------
  363. if Moss_on_trunk == true then
  364. abstract_trunks.grow_moss_on_trunk = function(pos)
  365. local on_ground = {x=pos.x, y=pos.y+1, z=pos.z}
  366. local at_side_n = {x=pos.x, y=pos.y, z=pos.z+1}
  367. local at_side_e = {x=pos.x+1, y=pos.y, z=pos.z}
  368. local at_side_s = {x=pos.x, y=pos.y, z=pos.z-1}
  369. local at_side_w = {x=pos.x-1, y=pos.y, z=pos.z}
  370. local undrneath = {x=pos.x, y=pos.y-1, z=pos.z}
  371. local node_here = minetest.get_node(on_ground)
  372. local node_north = minetest.get_node(at_side_n)
  373. local node_east = minetest.get_node(at_side_e)
  374. local node_south = minetest.get_node(at_side_s)
  375. local node_west = minetest.get_node(at_side_w)
  376. local node_under = minetest.get_node(undrneath)
  377. --if minetest.get_item_group(node_under.name, "tree") < 1 then
  378. local moss_type = math.random(1,41)
  379. if minetest.registered_nodes[node_here.name].buildable_to then -- instead of check_air = true,
  380. if moss_type == 1 then
  381. minetest.swap_node(on_ground, {name="trunks:moss_fungus", param2=math.random(0,3) --[[1]]})
  382. elseif moss_type < 22 then
  383. minetest.swap_node(on_ground, {name="trunks:moss", param2=math.random(0,3) --[[1]]})
  384. end
  385. end
  386. local moss_type = math.random(1,31) -- cliche of more moss at north
  387. if minetest.registered_nodes[node_north.name].buildable_to then -- instead of check_air = true,
  388. if moss_type == 1 then
  389. minetest.swap_node(at_side_n, {name="trunks:moss_fungus", param2=math.random(4,7)}) -- 5,4,6,7
  390. elseif moss_type < 22 then
  391. minetest.swap_node(at_side_n, {name="trunks:moss", param2=math.random(4,7)})
  392. end
  393. end
  394. local moss_type = math.random(1,41)
  395. if minetest.registered_nodes[node_east.name].buildable_to then -- instead of check_air = true,
  396. if moss_type == 1 then
  397. minetest.swap_node(at_side_e, {name="trunks:moss_fungus", param2=math.random(12,15)})
  398. elseif moss_type < 22 then
  399. minetest.swap_node(at_side_e, {name="trunks:moss", param2=math.random(12,15)})
  400. end
  401. end
  402. local moss_type = math.random(1,41)
  403. if minetest.registered_nodes[node_south.name].buildable_to then -- instead of check_air = true,
  404. if moss_type == 1 then
  405. minetest.swap_node(at_side_s, {name="trunks:moss_fungus", param2=math.random(8,11)})
  406. elseif moss_type < 22 then
  407. minetest.swap_node(at_side_s, {name="trunks:moss", param2=math.random(8,11)})
  408. end
  409. end
  410. local moss_type = math.random(1,41)
  411. if minetest.registered_nodes[node_west.name].buildable_to then -- instead of check_air = true,
  412. if moss_type == 1 then
  413. minetest.swap_node(at_side_w, {name="trunks:moss_fungus", param2=math.random(16,19)})
  414. elseif moss_type < 22 then
  415. minetest.swap_node(at_side_w, {name="trunks:moss", param2=math.random(16,19)})
  416. end
  417. end
  418. --end
  419. end
  420. biome_lib:register_generate_plant({
  421. surface = {
  422. "default:tree",
  423. "default:jungletree",
  424. "default:pine_tree",
  425. "trees:tree_conifer",
  426. "trees:tree_mangrove",
  427. --"trees:tree_palm",
  428. "moretrees:apple_tree_trunk",
  429. "moretrees:beech_trunk",
  430. "moretrees:birch_trunk",
  431. "moretrees:fir_trunk",
  432. "moretrees:oak_trunk",
  433. --"moretrees:palm_trunk",
  434. "moretrees:rubber_tree_trunk",
  435. "moretrees:rubber_tree_trunk_empty",
  436. "moretrees:sequoia_trunk",
  437. "moretrees:spruce_trunk",
  438. "moretrees:willow_trunk",
  439. "default:mossycobble"
  440. },
  441. max_count = Moss_on_trunk_Max_Count,
  442. rarity = Moss_on_trunk_Rarity,
  443. min_elevation = 1,
  444. max_elevation = 40,
  445. plantlife_limit = -0.9,
  446. check_air = false,
  447. },
  448. "abstract_trunks.grow_moss_on_trunk"
  449. )
  450. end
  451. -----------------------------------------------------------------------------------------------
  452. -- RooTS
  453. -----------------------------------------------------------------------------------------------
  454. if Roots == true then -- see settings.txt
  455. abstract_trunks.grow_roots = function(pos)
  456. local twig_size = math.random(1,27)
  457. local right_here = {x=pos.x , y=pos.y , z=pos.z }
  458. local below = {x=pos.x , y=pos.y-1, z=pos.z }
  459. local north = {x=pos.x , y=pos.y , z=pos.z+1}
  460. local east = {x=pos.x+1, y=pos.y , z=pos.z }
  461. local south = {x=pos.x , y=pos.y , z=pos.z-1}
  462. local west = {x=pos.x-1, y=pos.y , z=pos.z }
  463. local node_here = minetest.get_node(right_here)
  464. local node_below = minetest.get_node(below)
  465. local node_north = minetest.get_node(north)
  466. local node_east = minetest.get_node(east)
  467. local node_south = minetest.get_node(south)
  468. local node_west = minetest.get_node(west)
  469. for i in pairs(TRuNKS) do
  470. local MoD = TRuNKS[i][1]
  471. local TRuNK = TRuNKS[i][2]
  472. if minetest.get_modpath(MoD) ~= nil
  473. and node_here.name == MoD..":"..TRuNK
  474. and string.find(node_below.name, "dirt")
  475. and node_here.param2 == 0 then
  476. if minetest.registered_nodes[node_north.name].buildable_to then
  477. minetest.swap_node(north, {name="trunks:"..TRuNK.."root", param2=2})
  478. end
  479. if minetest.registered_nodes[node_east.name].buildable_to then
  480. minetest.swap_node(east, {name="trunks:"..TRuNK.."root", param2=3})
  481. end
  482. if minetest.registered_nodes[node_south.name].buildable_to then
  483. minetest.swap_node(south, {name="trunks:"..TRuNK.."root", param2=0})
  484. end
  485. if minetest.registered_nodes[node_west.name].buildable_to then
  486. minetest.swap_node(west, {name="trunks:"..TRuNK.."root", param2=1})
  487. end
  488. end
  489. end
  490. end
  491. biome_lib:register_generate_plant({
  492. surface = {"group:tree"},
  493. max_count = 1000,
  494. rarity = 1,
  495. min_elevation = 1,
  496. max_elevation = 40,
  497. near_nodes = {"default:dirt_with_grass"},
  498. near_nodes_size = 1,
  499. near_nodes_vertical = 1,
  500. near_nodes_count = 1,
  501. plantlife_limit = -1,
  502. check_air = false,
  503. },
  504. "abstract_trunks.grow_roots"
  505. )
  506. end