functions.lua 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. -- TREE FUNCTIONS
  2. local function check_add_node(pos, name)
  3. local nn = minetest.get_node(pos).name
  4. if nn == "air" or minetest.get_item_group(nn, "sapling") then
  5. minetest.set_node(pos, name)
  6. end
  7. end
  8. -- Alders
  9. function lottplants_aldertree(pos)
  10. local t = 6 + math.random(2) -- trunk height
  11. for j = -2, t do
  12. if j == t or j == t - 2 then
  13. for i = -2, 2 do
  14. for k = -2, 2 do
  15. local absi = math.abs(i)
  16. local absk = math.abs(k)
  17. if math.random() > (absi + absk) / 24 then
  18. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:alderleaf"})
  19. end
  20. end
  21. end
  22. end
  23. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="lottplants:aldertree"})
  24. end
  25. end
  26. -- Apple tree
  27. function lottplants_appletree(pos)
  28. local t = 4 + math.random(2) -- trunk height
  29. for j = -2, t do
  30. if j == t or j == t - 2 then
  31. for i = -2, 2 do
  32. for k = -2, 2 do
  33. local absi = math.abs(i)
  34. local absk = math.abs(k)
  35. if math.random() > (absi + absk) / 24 then
  36. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:appleleaf"})
  37. end
  38. if math.random() > (absi + absk) / 12 then
  39. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="default:apple"})
  40. end
  41. end
  42. end
  43. end
  44. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="default:tree"})
  45. end
  46. end
  47. -- Birches
  48. function lottplants_birchtree(pos)
  49. local t = 7 + math.random(5) -- trunk height
  50. for j = -3, t do
  51. if j == math.floor(t * 0.7) or j == t then
  52. for i = -2, 2 do
  53. for k = -2, 2 do
  54. local absi = math.abs(i)
  55. local absk = math.abs(k)
  56. if math.random() > (absi + absk) / 24 then
  57. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:birchleaf"})
  58. end
  59. end
  60. end
  61. end
  62. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="lottplants:birchtree"})
  63. end
  64. end
  65. -- Beeches
  66. function lottplants_beechtree(pos)
  67. local t = 10 + math.random(3) -- trunk height
  68. for i = -2, 2 do
  69. for k = -2, 2 do
  70. local absi = math.abs(i)
  71. local absk = math.abs(k)
  72. if absi >= absk then
  73. j = t - absi
  74. else
  75. j = t - absk
  76. end
  77. if math.random() > (absi + absk) / 24 then
  78. check_add_node({x=pos.x+i,y=pos.y+j+7,z=pos.z+k},{name="lottplants:beechleaf"})
  79. check_add_node({x=pos.x+i,y=pos.y+j+4,z=pos.z+k},{name="lottplants:beechleaf"})
  80. check_add_node({x=pos.x+i+2,y=pos.y+j+4,z=pos.z+k},{name="lottplants:beechleaf"})
  81. check_add_node({x=pos.x+i-2,y=pos.y+j+4,z=pos.z+k},{name="lottplants:beechleaf"})
  82. check_add_node({x=pos.x+i,y=pos.y+j+4,z=pos.z+k+2},{name="lottplants:beechleaf"})
  83. check_add_node({x=pos.x+i,y=pos.y+j+4,z=pos.z+k-2},{name="lottplants:beechleaf"})
  84. check_add_node({x=pos.x+i,y=pos.y+j+1,z=pos.z+k},{name="lottplants:beechleaf"})
  85. check_add_node({x=pos.x+i+3,y=pos.y+j+1,z=pos.z+k},{name="lottplants:beechleaf"})
  86. check_add_node({x=pos.x+i-3,y=pos.y+j+1,z=pos.z+k},{name="lottplants:beechleaf"})
  87. check_add_node({x=pos.x+i,y=pos.y+j+1,z=pos.z+k+3},{name="lottplants:beechleaf"})
  88. check_add_node({x=pos.x+i,y=pos.y+j+1,z=pos.z+k-3},{name="lottplants:beechleaf"})
  89. check_add_node({x=pos.x+i,y=pos.y+j-2,z=pos.z+k},{name="lottplants:beechleaf"})
  90. check_add_node({x=pos.x+i+3,y=pos.y+j-2,z=pos.z+k},{name="lottplants:beechleaf"})
  91. check_add_node({x=pos.x+i-3,y=pos.y+j-2,z=pos.z+k},{name="lottplants:beechleaf"})
  92. check_add_node({x=pos.x+i,y=pos.y+j-2,z=pos.z+k+3},{name="lottplants:beechleaf"})
  93. check_add_node({x=pos.x+i,y=pos.y+j-2,z=pos.z+k-3},{name="lottplants:beechleaf"})
  94. check_add_node({x=pos.x+i,y=pos.y+j-5,z=pos.z+k},{name="lottplants:beechleaf"})
  95. check_add_node({x=pos.x+i+4,y=pos.y+j-5,z=pos.z+k},{name="lottplants:beechleaf"})
  96. check_add_node({x=pos.x+i-4,y=pos.y+j-5,z=pos.z+k},{name="lottplants:beechleaf"})
  97. check_add_node({x=pos.x+i,y=pos.y+j-5,z=pos.z+k+4},{name="lottplants:beechleaf"})
  98. check_add_node({x=pos.x+i,y=pos.y+j-5,z=pos.z+k-4},{name="lottplants:beechleaf"})
  99. check_add_node({x=pos.x+i,y=pos.y+j-8,z=pos.z+k},{name="lottplants:beechleaf"})
  100. check_add_node({x=pos.x+i+4,y=pos.y+j-8,z=pos.z+k},{name="lottplants:beechleaf"})
  101. check_add_node({x=pos.x+i-4,y=pos.y+j-8,z=pos.z+k},{name="lottplants:beechleaf"})
  102. check_add_node({x=pos.x+i,y=pos.y+j-8,z=pos.z+k+4},{name="lottplants:beechleaf"})
  103. check_add_node({x=pos.x+i,y=pos.y+j-8,z=pos.z+k-4},{name="lottplants:beechleaf"})
  104. end
  105. end
  106. end
  107. for j = -3, t do
  108. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="default:tree"})
  109. end
  110. end
  111. -- Culumalda
  112. function lottplants_culumaldatree(pos)
  113. local t = 4 + math.random(2) -- trunk height
  114. for j = -2, t do
  115. if j == t or j == t - 2 then
  116. for i = -2, 2 do
  117. for k = -2, 2 do
  118. local absi = math.abs(i)
  119. local absk = math.abs(k)
  120. if math.random() > (absi + absk) / 24 then
  121. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:culumaldaleaf"})
  122. end
  123. if math.random() > (absi + absk) / 12 then
  124. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:yellowflowers"})
  125. end
  126. end
  127. end
  128. end
  129. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="default:tree"})
  130. end
  131. end
  132. -- Elms
  133. function lottplants_elmtree(pos)
  134. local t = 20 + math.random(5) -- trunk height
  135. for j = -3, t do
  136. if j == math.floor(t * 0.7) or j == t then
  137. for i = -2, 2 do
  138. for k = -2, 2 do
  139. local absi = math.abs(i)
  140. local absk = math.abs(k)
  141. if math.random() > (absi + absk) / 24 then
  142. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:elmleaf"})
  143. end
  144. end
  145. end
  146. end
  147. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="default:tree"})
  148. end
  149. end
  150. -- Firs
  151. function lottplants_firtree(pos)
  152. local t = 10 + math.random(3) -- trunk height
  153. for i = -2, 2 do
  154. for k = -2, 2 do
  155. local absi = math.abs(i)
  156. local absk = math.abs(k)
  157. if absi >= absk then
  158. j = t - absi
  159. else
  160. j = t - absk
  161. end
  162. if math.random() > (absi + absk) / 24 then
  163. check_add_node({x=pos.x+i,y=pos.y+j+1,z=pos.z+k},{name="lottplants:firleaf"})
  164. check_add_node({x=pos.x+i,y=pos.y+j-2,z=pos.z+k},{name="lottplants:firleaf"})
  165. check_add_node({x=pos.x+i,y=pos.y+j-5,z=pos.z+k},{name="lottplants:firleaf"})
  166. end
  167. end
  168. end
  169. for j = -3, t do
  170. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="lottplants:pinetree"})
  171. end
  172. end
  173. -- Lebethron
  174. function lottplants_lebethrontree(pos)
  175. local t = 3 + math.random(1) -- trunk height
  176. for j = -3, t do
  177. if j == math.floor(t * 0.7) or j == t then
  178. for i = -2, 2 do
  179. for k = -2, 2 do
  180. local absi = math.abs(i)
  181. local absk = math.abs(k)
  182. if math.random() > (absi + absk) / 24 then
  183. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:lebethronleaf"})
  184. end
  185. end
  186. end
  187. end
  188. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="lottplants:lebethrontree"})
  189. end
  190. end
  191. -- Mallorn
  192. function add_tree_branch_mallorn(pos)
  193. check_add_node(pos, {name="lottplants:mallorntree"})
  194. for i = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do
  195. for k = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do
  196. local p = {x=pos.x+i, y=pos.y, z=pos.z+k}
  197. check_add_node(p, {name="lottplants:mallornleaf"})
  198. local chance = math.abs(i+k)
  199. if (chance < 1) then
  200. p = {x=pos.x+i, y=pos.y+1, z=pos.z+k}
  201. check_add_node(p, {name="lottplants:mallornleaf"})
  202. end
  203. end
  204. end
  205. end
  206. function lottplants_mallorntree(pos)
  207. local height = 25 + math.random(5)
  208. if height < 10 then
  209. for i = height, -2, -1 do
  210. local p = {x=pos.x, y=pos.y+i, z=pos.z}
  211. check_add_node(p, {name="lottplants:mallorntree"})
  212. if i == height then
  213. add_tree_branch_mallorn({x=pos.x, y=pos.y+height+math.random(0, 1), z=pos.z})
  214. add_tree_branch_mallorn({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z})
  215. add_tree_branch_mallorn({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z})
  216. add_tree_branch_mallorn({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1})
  217. add_tree_branch_mallorn({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1})
  218. end
  219. if i < 0 then
  220. check_add_node({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z}, {name="lottplants:mallorntree"})
  221. check_add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1}, {name="lottplants:mallorntree"})
  222. check_add_node({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z}, {name="lottplants:mallorntree"})
  223. check_add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1}, {name="lottplants:mallorntree"})
  224. end
  225. if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then
  226. local branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)}
  227. add_tree_branch_mallorn(branch_pos)
  228. end
  229. end
  230. else
  231. for i = height, -5, -1 do
  232. if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then
  233. local branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)}
  234. add_tree_branch_mallorn(branch_pos)
  235. end
  236. if i < math.random(0,1) then
  237. check_add_node({x=pos.x+1, y=pos.y+i, z=pos.z+1}, {name="lottplants:mallorntree"})
  238. check_add_node({x=pos.x+2, y=pos.y+i, z=pos.z-1}, {name="lottplants:mallorntree"})
  239. check_add_node({x=pos.x, y=pos.y+i, z=pos.z-2}, {name="lottplants:mallorntree"})
  240. check_add_node({x=pos.x-1, y=pos.y+i, z=pos.z}, {name="lottplants:mallorntree"})
  241. end
  242. if i == height then
  243. add_tree_branch_mallorn({x=pos.x+1, y=pos.y+i, z=pos.z+1})
  244. add_tree_branch_mallorn({x=pos.x+2, y=pos.y+i, z=pos.z-1})
  245. add_tree_branch_mallorn({x=pos.x, y=pos.y+i, z=pos.z-2})
  246. add_tree_branch_mallorn({x=pos.x-1, y=pos.y+i, z=pos.z})
  247. add_tree_branch_mallorn({x=pos.x+1, y=pos.y+i, z=pos.z+2})
  248. add_tree_branch_mallorn({x=pos.x+3, y=pos.y+i, z=pos.z-1})
  249. add_tree_branch_mallorn({x=pos.x, y=pos.y+i, z=pos.z-3})
  250. add_tree_branch_mallorn({x=pos.x-2, y=pos.y+i, z=pos.z})
  251. add_tree_branch_mallorn({x=pos.x+1, y=pos.y+i, z=pos.z})
  252. add_tree_branch_mallorn({x=pos.x+1, y=pos.y+i, z=pos.z-1})
  253. add_tree_branch_mallorn({x=pos.x, y=pos.y+i, z=pos.z-1})
  254. add_tree_branch_mallorn({x=pos.x, y=pos.y+i, z=pos.z})
  255. else
  256. check_add_node({x=pos.x+1, y=pos.y+i, z=pos.z}, {name="lottplants:mallorntree"})
  257. check_add_node({x=pos.x+1, y=pos.y+i, z=pos.z-1}, {name="lottplants:mallorntree"})
  258. check_add_node({x=pos.x, y=pos.y+i, z=pos.z-1}, {name="lottplants:mallorntree"})
  259. check_add_node({x=pos.x, y=pos.y+i, z=pos.z}, {name="lottplants:mallorntree"})
  260. end
  261. end
  262. end
  263. end
  264. function lottplants_smallmallorntree(pos)
  265. for j = -3, 15 do
  266. if j == 11 or j == 15 then
  267. for i = -2, 2 do
  268. for k = -2, 2 do
  269. local absi = math.abs(i)
  270. local absk = math.abs(k)
  271. if math.random() > (absi + absk) / 24 then
  272. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:mallornleaf"})
  273. end
  274. end
  275. end
  276. end
  277. end
  278. for j = -3, 15 do
  279. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="lottplants:mallorntree"})
  280. if j == 0 then
  281. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="lottplants:mallorntree_grower"})
  282. end
  283. end
  284. end
  285. function lottplants_young_mallorn(pos)
  286. local t = 6 + math.random(1) -- trunk height
  287. for j = 0, t do
  288. if j == t or j == t - 2 then
  289. for i = -1, 1 do
  290. for k = -1, 1 do
  291. local absi = math.abs(i)
  292. local absk = math.abs(k)
  293. if math.random() > (absi + absk) / 24 then
  294. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:mallornleaf"})
  295. end
  296. end
  297. end
  298. end
  299. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="lottplants:mallorntree_young"})
  300. if j == 0 then
  301. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="lottplants:mallorntree_young_grower"})
  302. end
  303. end
  304. end
  305. -- Oaks
  306. function lottplants_oaktree(pos)
  307. local t = 10 + math.random(3) -- trunk height
  308. for i = -2, 2 do
  309. for k = -2, 2 do
  310. local absi = math.abs(i)
  311. local absk = math.abs(k)
  312. if absi >= absk then
  313. j = t - absi
  314. else
  315. j = t - absk
  316. end
  317. if math.random() > (absi + absk) / 24 then
  318. check_add_node({x=pos.x+i,y=pos.y+j+3,z=pos.z+k},{name="lottplants:firleaf"})
  319. check_add_node({x=pos.x+i,y=pos.y+j+1,z=pos.z+k},{name="lottplants:firleaf"})
  320. check_add_node({x=pos.x+i+1,y=pos.y+j-1,z=pos.z+k},{name="lottplants:firleaf"})
  321. check_add_node({x=pos.x+i,y=pos.y+j-2,z=pos.z+k+1},{name="lottplants:firleaf"})
  322. check_add_node({x=pos.x+i,y=pos.y+j-3,z=pos.z+k},{name="lottplants:firleaf"})
  323. check_add_node({x=pos.x+i,y=pos.y+j-4,z=pos.z+k},{name="lottplants:firleaf"})
  324. check_add_node({x=pos.x+i,y=pos.y+j-5,z=pos.z+k},{name="lottplants:firleaf"})
  325. end
  326. end
  327. end
  328. for j = -5, t do
  329. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="lottplants:pinetree"})
  330. end
  331. end
  332. -- Pines
  333. function lottplants_pinetree(pos)
  334. local t = 10 + math.random(3) -- trunk height
  335. for i = -2, 2 do
  336. for k = -2, 2 do
  337. local absi = math.abs(i)
  338. local absk = math.abs(k)
  339. if absi >= absk then
  340. j = t - absi
  341. else
  342. j = t - absk
  343. end
  344. if math.random() > (absi + absk) / 24 then
  345. check_add_node({x=pos.x+i,y=pos.y+j+1,z=pos.z+k},{name="lottplants:pineleaf"})
  346. check_add_node({x=pos.x+i,y=pos.y+j-2,z=pos.z+k},{name="lottplants:pineleaf"})
  347. check_add_node({x=pos.x+i+1,y=pos.y+j-2,z=pos.z+k},{name="lottplants:pineleaf"})
  348. check_add_node({x=pos.x+i-1,y=pos.y+j-2,z=pos.z+k},{name="lottplants:pineleaf"})
  349. check_add_node({x=pos.x+i,y=pos.y+j-2,z=pos.z+k+1},{name="lottplants:pineleaf"})
  350. check_add_node({x=pos.x+i,y=pos.y+j-2,z=pos.z+k-1},{name="lottplants:pineleaf"})
  351. check_add_node({x=pos.x+i,y=pos.y+j-5,z=pos.z+k},{name="lottplants:pineleaf"})
  352. check_add_node({x=pos.x+i+1,y=pos.y+j-5,z=pos.z+k},{name="lottplants:pineleaf"})
  353. check_add_node({x=pos.x+i-1,y=pos.y+j-5,z=pos.z+k},{name="lottplants:pineleaf"})
  354. check_add_node({x=pos.x+i,y=pos.y+j-5,z=pos.z+k+1},{name="lottplants:pineleaf"})
  355. check_add_node({x=pos.x+i,y=pos.y+j-5,z=pos.z+k-1},{name="lottplants:pineleaf"})
  356. check_add_node({x=pos.x+i,y=pos.y+j-8,z=pos.z+k},{name="lottplants:pineleaf"})
  357. check_add_node({x=pos.x+i+2,y=pos.y+j-8,z=pos.z+k},{name="lottplants:pineleaf"})
  358. check_add_node({x=pos.x+i-2,y=pos.y+j-8,z=pos.z+k},{name="lottplants:pineleaf"})
  359. check_add_node({x=pos.x+i,y=pos.y+j-8,z=pos.z+k+2},{name="lottplants:pineleaf"})
  360. check_add_node({x=pos.x+i,y=pos.y+j-8,z=pos.z+k-2},{name="lottplants:pineleaf"})
  361. end
  362. end
  363. end
  364. for j = -3, t do
  365. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="lottplants:pinetree"})
  366. end
  367. end
  368. -- Plum Trees
  369. function lottplants_plumtree(pos)
  370. local t = 3 + math.random(2) -- trunk height
  371. for j = -2, t do
  372. if j == t or j == t - 2 then
  373. for i = -2, 2 do
  374. for k = -2, 2 do
  375. local absi = math.abs(i)
  376. local absk = math.abs(k)
  377. if math.random() > (absi + absk) / 24 then
  378. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:plumleaf"})
  379. end
  380. if math.random() > (absi + absk) / 2 then
  381. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:plum"})
  382. end
  383. end
  384. end
  385. end
  386. if j ~= t then
  387. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="default:tree"})
  388. end
  389. end
  390. end
  391. -- Rowans
  392. function lottplants_rowantree(pos)
  393. local t = 4 + math.random(2) -- trunk height
  394. for j = -2, t do
  395. if j == t or j == t - 2 then
  396. for i = -2, 2 do
  397. for k = -2, 2 do
  398. local absi = math.abs(i)
  399. local absk = math.abs(k)
  400. if math.random() > (absi + absk) / 12 then
  401. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:rowanleaf"})
  402. end
  403. end
  404. end
  405. end
  406. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="default:tree"})
  407. end
  408. end
  409. -- White Tree
  410. function lottplants_whitetree(pos)
  411. local t = 6 + math.random(2) -- trunk height
  412. for j = -2, t do
  413. if j == t or j == t - 2 or j == t - 4 then
  414. for i = -3, 3 do
  415. for k = -3, 3 do
  416. local absi = math.abs(i)
  417. local absk = math.abs(k)
  418. if math.random() > (absi + absk) / 24 then
  419. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:whiteleaf"})
  420. end
  421. end
  422. end
  423. end
  424. if j == t - 1 then
  425. for i = -2, 2 do
  426. for k = -2, 2 do
  427. if i == -1 and k == 0 or i == 1 and k == 0
  428. or k == 1 and i == 0 or k == -1 and i == 0
  429. or i == -2 and k == 0 or i == 2 and k == 0
  430. or k == 2 and i == 0 or k == -2 and i == 0 then
  431. check_add_node({x = pos.x + i, y = pos.y + j, z = pos.z}, {name="default:tree", param2 = 16})
  432. check_add_node({x = pos.x, y = pos.y + j, z = pos.z + k}, {name="default:tree", param2 = 10})
  433. end
  434. end
  435. end
  436. end
  437. check_add_node({x=pos.x,y=pos.y+j,z=pos.z}, {name="default:tree"})
  438. end
  439. end
  440. -- Yavannamire
  441. function lottplants_yavannamiretree(pos)
  442. local t = 4 + math.random(2) -- trunk height
  443. for j = -2, t do
  444. if j == t or j == t - 2 then
  445. for i = -2, 2 do
  446. for k = -2, 2 do
  447. local absi = math.abs(i)
  448. local absk = math.abs(k)
  449. if math.random() > (absi + absk) / 24 then
  450. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:yavannamireleaf"})
  451. end
  452. if math.random() > (absi + absk) / 12 then
  453. check_add_node({x=pos.x+i,y=pos.y+j+math.random(0, 1),z=pos.z+k},{name="lottplants:yavannamirefruit"})
  454. end
  455. end
  456. end
  457. end
  458. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="default:tree"})
  459. end
  460. end
  461. --Mirk large
  462. function add_tree_branch_mirktree(pos)
  463. check_add_node(pos, {name="default:jungletree"})
  464. for i = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do
  465. for k = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do
  466. local p = {x=pos.x+i, y=pos.y, z=pos.z+k}
  467. local n = minetest.get_node(p)
  468. if (n.name=="air") then
  469. check_add_node(p, {name="lottplants:mirkleaf"})
  470. end
  471. local chance = math.abs(i+k)
  472. if (chance < 1) then
  473. p = {x=pos.x+i, y=pos.y+1, z=pos.z+k}
  474. n = minetest.get_node(p)
  475. if (n.name=="air") then
  476. check_add_node(p, {name="lottplants:mirkleaf"})
  477. end
  478. end
  479. end
  480. end
  481. end
  482. function lottplants_mirktree(pos)
  483. local height = 5 + math.random(1)
  484. if height < 1 then
  485. for i = height, -2, -1 do
  486. local p = {x=pos.x, y=pos.y+i, z=pos.z}
  487. check_add_node(p, {name="default:jungletree"})
  488. if i == height then
  489. add_tree_branch_mirktree({x=pos.x, y=pos.y+height+math.random(0, 1), z=pos.z})
  490. add_tree_branch_mirktree({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z})
  491. add_tree_branch_mirktree({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z})
  492. add_tree_branch_mirktree({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1})
  493. add_tree_branch_mirktree({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1})
  494. end
  495. if i < 0 then
  496. check_add_node({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z}, {name="default:jungletree"})
  497. check_add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1}, {name="default:jungletree"})
  498. check_add_node({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z}, {name="default:jungletree"})
  499. check_add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1}, {name="default:jungletree"})
  500. end
  501. if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then
  502. local branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)}
  503. add_tree_branch_mirktree(branch_pos)
  504. end
  505. end
  506. else
  507. for i = height, -5, -1 do
  508. if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then
  509. local branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)}
  510. add_tree_branch_mirktree(branch_pos)
  511. end
  512. if i < math.random(0,1) then
  513. check_add_node({x=pos.x+1, y=pos.y+i, z=pos.z+1}, {name="default:jungletree"})
  514. check_add_node({x=pos.x+2, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"})
  515. check_add_node({x=pos.x, y=pos.y+i, z=pos.z-2}, {name="default:jungletree"})
  516. check_add_node({x=pos.x-1, y=pos.y+i, z=pos.z}, {name="default:jungletree"})
  517. end
  518. if i == height then
  519. add_tree_branch_mirktree({x=pos.x+1, y=pos.y+i, z=pos.z+1})
  520. add_tree_branch_mirktree({x=pos.x+2, y=pos.y+i, z=pos.z-1})
  521. add_tree_branch_mirktree({x=pos.x, y=pos.y+i, z=pos.z-2})
  522. add_tree_branch_mirktree({x=pos.x-1, y=pos.y+i, z=pos.z})
  523. add_tree_branch_mirktree({x=pos.x+1, y=pos.y+i, z=pos.z+2})
  524. add_tree_branch_mirktree({x=pos.x+3, y=pos.y+i, z=pos.z-1})
  525. add_tree_branch_mirktree({x=pos.x, y=pos.y+i, z=pos.z-3})
  526. add_tree_branch_mirktree({x=pos.x-2, y=pos.y+i, z=pos.z})
  527. add_tree_branch_mirktree({x=pos.x+1, y=pos.y+i, z=pos.z})
  528. add_tree_branch_mirktree({x=pos.x+1, y=pos.y+i, z=pos.z-1})
  529. add_tree_branch_mirktree({x=pos.x, y=pos.y+i, z=pos.z-1})
  530. add_tree_branch_mirktree({x=pos.x, y=pos.y+i, z=pos.z})
  531. else
  532. check_add_node({x=pos.x+1, y=pos.y+i, z=pos.z}, {name="default:jungletree"})
  533. check_add_node({x=pos.x+1, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"})
  534. check_add_node({x=pos.x, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"})
  535. check_add_node({x=pos.x, y=pos.y+i, z=pos.z}, {name="default:jungletree"})
  536. end
  537. end
  538. end
  539. end
  540. --Mirk Small
  541. function lottplants_smallmirktree(pos)
  542. for j = -3, 7 do
  543. if j == 6 then
  544. for i = -4, 4 do
  545. for k = -4, 4 do
  546. if math.random(20) ~= 10 then
  547. check_add_node({x=pos.x+i,y=pos.y+j+math.random(1, 2),z=pos.z+k},{name="lottplants:mirkleaf"})
  548. end
  549. end
  550. end
  551. for i = -1, 1, 2 do
  552. for k = -1, 1, 2 do
  553. check_add_node({x=pos.x+i,y=pos.y+j,z=pos.z+k},{name="default:jungletree"})
  554. end
  555. end
  556. elseif j == 7 then
  557. for i = -2, 2, 4 do
  558. for k = -2, 2, 4 do
  559. check_add_node({x=pos.x+i,y=pos.y+j,z=pos.z+k},{name="default:jungletree"})
  560. end
  561. end
  562. else
  563. check_add_node({x=pos.x,y=pos.y+j,z=pos.z},{name="default:jungletree"})
  564. end
  565. end
  566. end
  567. -- SAPLINGS
  568. local function can_grow(pos)
  569. local node = minetest.get_node_or_nil({x = pos.x, y = pos.y, z = pos.z})
  570. if not node then
  571. return false
  572. end
  573. local growable_nodes = { "soil", "stone", "sand", "water" }
  574. for i, growable_node in ipairs (growable_nodes) do
  575. if minetest.get_item_group(node.name, growable_node) ~= 0 then
  576. return true
  577. end
  578. end
  579. if "air" == node.name then
  580. return true
  581. end
  582. return false
  583. end
  584. local function large_roots(pos)
  585. for j = -5, 0 do
  586. for i = -1, 2 do
  587. for k = -1, 2 do
  588. if i == 0 and j == 0 and k == 0 then
  589. -- This is the sapling, ignore it
  590. elseif not can_grow({x = pos.x + i, y = pos.y + j, z = pos.z + k}) then
  591. return false
  592. end
  593. end
  594. end
  595. end
  596. return true
  597. end
  598. -- Alders sapling
  599. minetest.register_abm({
  600. nodenames = {"lottplants:aldersapling"},
  601. interval = 67,
  602. chance = 11,
  603. action = function(pos, node, active_object_count, active_object_count_wider)
  604. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  605. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) then
  606. local light_level = minetest.get_node_light(pos)
  607. if not light_level then
  608. return
  609. end
  610. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  611. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  612. lottplants_aldertree(pos)
  613. end
  614. end
  615. end,
  616. })
  617. -- Apple Tree sapling
  618. minetest.register_abm({
  619. nodenames = {"lottplants:applesapling"},
  620. interval = 67,
  621. chance = 11,
  622. action = function(pos, node, active_object_count, active_object_count_wider)
  623. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  624. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) then
  625. local light_level = minetest.get_node_light(pos)
  626. if not light_level then
  627. return
  628. end
  629. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  630. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  631. lottplants_appletree(pos)
  632. end
  633. end
  634. end,
  635. })
  636. -- Birch sapling
  637. minetest.register_abm({
  638. nodenames = {"lottplants:birchsapling"},
  639. interval = 67,
  640. chance = 11,
  641. action = function(pos, node, active_object_count, active_object_count_wider)
  642. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  643. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) and
  644. can_grow({x = pos.x, y = pos.y - 3, z = pos.z}) then
  645. local light_level = minetest.get_node_light(pos)
  646. if not light_level then
  647. return
  648. end
  649. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  650. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  651. lottplants_birchtree(pos)
  652. end
  653. end
  654. end,
  655. })
  656. -- Beech sapling
  657. minetest.register_abm({
  658. nodenames = {"lottplants:beechsapling"},
  659. interval = 67,
  660. chance = 11,
  661. action = function(pos, node, active_object_count, active_object_count_wider)
  662. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  663. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) and
  664. can_grow({x = pos.x, y = pos.y - 3, z = pos.z}) then
  665. local light_level = minetest.get_node_light(pos)
  666. if not light_level then
  667. return
  668. end
  669. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  670. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  671. lottplants_beechtree(pos)
  672. end
  673. end
  674. end,
  675. })
  676. -- Culumalda sapling
  677. minetest.register_abm({
  678. nodenames = {"lottplants:culumaldasapling"},
  679. interval = 67,
  680. chance = 11,
  681. action = function(pos, node, active_object_count, active_object_count_wider)
  682. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  683. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) then
  684. local light_level = minetest.get_node_light(pos)
  685. if not light_level then
  686. return
  687. end
  688. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  689. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  690. lottplants_culumaldatree(pos)
  691. end
  692. end
  693. end,
  694. })
  695. -- Elm sapling
  696. minetest.register_abm({
  697. nodenames = {"lottplants:elmsapling"},
  698. interval = 67,
  699. chance = 11,
  700. action = function(pos, node, active_object_count, active_object_count_wider)
  701. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  702. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) and
  703. can_grow({x = pos.x, y = pos.y - 3, z = pos.z}) then
  704. local light_level = minetest.get_node_light(pos)
  705. if not light_level then
  706. return
  707. end
  708. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  709. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  710. lottplants_elmtree(pos)
  711. end
  712. end
  713. end,
  714. })
  715. -- Fir sapling
  716. minetest.register_abm({
  717. nodenames = {"lottplants:firsapling"},
  718. interval = 67,
  719. chance = 11,
  720. action = function(pos, node, active_object_count, active_object_count_wider)
  721. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  722. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) and
  723. can_grow({x = pos.x, y = pos.y - 3, z = pos.z}) then
  724. local light_level = minetest.get_node_light(pos)
  725. if not light_level then
  726. return
  727. end
  728. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  729. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  730. lottplants_firtree(pos)
  731. end
  732. end
  733. end,
  734. })
  735. -- Lebethron sapling
  736. minetest.register_abm({
  737. nodenames = {"lottplants:lebethronsapling"},
  738. interval = 67,
  739. chance = 11,
  740. action = function(pos, node, active_object_count, active_object_count_wider)
  741. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  742. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) and
  743. can_grow({x = pos.x, y = pos.y - 3, z = pos.z}) then
  744. local light_level = minetest.get_node_light(pos)
  745. if not light_level then
  746. return
  747. end
  748. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  749. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  750. lottplants_lebethrontree(pos)
  751. end
  752. end
  753. end,
  754. })
  755. -- Mallorn sapling
  756. minetest.register_abm({
  757. nodenames = {"lottplants:mallornsapling"},
  758. interval = 67,
  759. chance = 11,
  760. action = function(pos, node, active_object_count, active_object_count_wider)
  761. local light_level = minetest.get_node_light(pos)
  762. if not light_level then
  763. return
  764. end
  765. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  766. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  767. lottplants_young_mallorn(pos)
  768. end
  769. end,
  770. })
  771. minetest.register_abm({
  772. nodenames = {"lottplants:mallorntree_young_grower"},
  773. interval = 67,
  774. chance = 25,
  775. action = function(pos, node, active_object_count, active_object_count_wider)
  776. local na = minetest.get_node_or_nil({x = pos.x, y = pos.y + 1, z = pos.z})
  777. local naa = minetest.get_node_or_nil({x = pos.x, y = pos.y + 2, z = pos.z})
  778. if na and naa and na.name == "lottplants:mallorntree_young" and naa.name == "lottplants:mallorntree_young" then
  779. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  780. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) and
  781. can_grow({x = pos.x, y = pos.y - 3, z = pos.z}) then
  782. local light_level = minetest.get_node_light(pos)
  783. if not light_level then
  784. return
  785. end
  786. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  787. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  788. lottplants_smallmallorntree(pos)
  789. end
  790. end
  791. end
  792. end,
  793. })
  794. minetest.register_abm({
  795. nodenames = {"lottplants:mallorntree_grower"},
  796. interval = 67,
  797. chance = 50,
  798. action = function(pos, node, active_object_count, active_object_count_wider)
  799. local na = minetest.get_node_or_nil({x = pos.x, y = pos.y + 1, z = pos.z})
  800. local naa = minetest.get_node_or_nil({x = pos.x, y = pos.y + 2, z = pos.z})
  801. if na and naa and na.name == "lottplants:mallorntree" and naa.name == "lottplants:mallorntree" then
  802. if large_roots(pos) ~= false then
  803. local light_level = minetest.get_node_light(pos)
  804. if not light_level then
  805. return
  806. end
  807. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  808. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  809. lottplants_mallorntree(pos)
  810. end
  811. end
  812. end
  813. end,
  814. })
  815. -- Pine sapling
  816. minetest.register_abm({
  817. nodenames = {"lottplants:pinesapling"},
  818. interval = 67,
  819. chance = 11,
  820. action = function(pos, node, active_object_count, active_object_count_wider)
  821. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  822. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) and
  823. can_grow({x = pos.x, y = pos.y - 3, z = pos.z}) then
  824. local light_level = minetest.get_node_light(pos)
  825. if not light_level then
  826. return
  827. end
  828. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  829. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  830. lottplants_pinetree(pos)
  831. end
  832. end
  833. end,
  834. })
  835. -- Plum sapling
  836. minetest.register_abm({
  837. nodenames = {"lottplants:plumsapling"},
  838. interval = 67,
  839. chance = 11,
  840. action = function(pos, node, active_object_count, active_object_count_wider)
  841. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  842. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) then
  843. local light_level = minetest.get_node_light(pos)
  844. if not light_level then
  845. return
  846. end
  847. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  848. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  849. lottplants_plumtree(pos)
  850. end
  851. end
  852. end,
  853. })
  854. -- Rowan sapling
  855. minetest.register_abm({
  856. nodenames = {"lottplants:rowansapling"},
  857. interval = 67,
  858. chance = 11,
  859. action = function(pos, node, active_object_count, active_object_count_wider)
  860. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  861. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) then
  862. local light_level = minetest.get_node_light(pos)
  863. if not light_level then
  864. return
  865. end
  866. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  867. --print(light_level, c)
  868. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  869. lottplants_rowantree(pos)
  870. end
  871. end
  872. end,
  873. })
  874. -- White Tree
  875. minetest.register_abm({
  876. nodenames = {"lottplants:whitesapling"},
  877. interval = 67,
  878. chance = 11,
  879. action = function(pos, node, active_object_count, active_object_count_wider)
  880. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  881. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) then
  882. local light_level = minetest.get_node_light(pos)
  883. if not light_level then
  884. return
  885. end
  886. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  887. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  888. lottplants_whitetree(pos)
  889. end
  890. end
  891. end,
  892. })
  893. -- Yavannamire Tree
  894. minetest.register_abm({
  895. nodenames = {"lottplants:yavannamiresapling"},
  896. interval = 67,
  897. chance = 11,
  898. action = function(pos, node, active_object_count, active_object_count_wider)
  899. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  900. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) then
  901. local light_level = minetest.get_node_light(pos)
  902. if not light_level then
  903. return
  904. end
  905. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  906. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  907. lottplants_yavannamiretree(pos)
  908. end
  909. end
  910. end,
  911. })
  912. --Mirk Tree
  913. minetest.register_abm({
  914. nodenames = {"lottplants:mirksapling"},
  915. interval = 67,
  916. chance = 11,
  917. action = function(pos, node, active_object_count, active_object_count_wider)
  918. if math.random(2) == 1 and large_roots(pos) then
  919. local light_level = minetest.get_node_light(pos)
  920. if not light_level then
  921. return
  922. end
  923. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  924. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  925. lottplants_mirktree(pos)
  926. end
  927. else
  928. if can_grow({x = pos.x, y = pos.y - 1, z = pos.z}) and
  929. can_grow({x = pos.x, y = pos.y - 2, z = pos.z}) and
  930. can_grow({x = pos.x, y = pos.y - 3, z = pos.z}) then
  931. local light_level = minetest.get_node_light(pos)
  932. if not light_level then
  933. return
  934. end
  935. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  936. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  937. lottplants_smallmirktree(pos)
  938. end
  939. end
  940. end
  941. end,
  942. })