functions.lua 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  1. --Plants
  2. function lottmapgen_grass(data, vi, p2data)
  3. local c_grass1 = minetest.get_content_id("default:grass_1")
  4. local c_grass2 = minetest.get_content_id("default:grass_2")
  5. local c_grass3 = minetest.get_content_id("default:grass_3")
  6. local c_grass4 = minetest.get_content_id("default:grass_4")
  7. local c_grass5 = minetest.get_content_id("default:grass_5")
  8. local rand = math.random(5)
  9. if rand == 1 then
  10. data[vi] = c_grass1
  11. elseif rand == 2 then
  12. data[vi] = c_grass2
  13. elseif rand == 3 then
  14. data[vi] = c_grass3
  15. elseif rand == 4 then
  16. data[vi] = c_grass4
  17. else
  18. data[vi] = c_grass5
  19. end
  20. p2data[vi] = 40
  21. end
  22. function lottmapgen_lorien_grass(data, vi, p2data)
  23. local c_lorgrass1 = minetest.get_content_id("lottplants:lorien_grass_1")
  24. local c_lorgrass2 = minetest.get_content_id("lottplants:lorien_grass_2")
  25. local c_lorgrass3 = minetest.get_content_id("lottplants:lorien_grass_3")
  26. local c_lorgrass4 = minetest.get_content_id("lottplants:lorien_grass_4")
  27. local rand = math.random(4)
  28. if rand == 1 then
  29. data[vi] = c_lorgrass1
  30. elseif rand == 2 then
  31. data[vi] = c_lorgrass2
  32. elseif rand == 3 then
  33. data[vi] = c_lorgrass3
  34. else
  35. data[vi] = c_lorgrass4
  36. end
  37. p2data[vi] = 40
  38. end
  39. function lottmapgen_farmingplants(data, vi, p2data)
  40. local c_plant1 = minetest.get_content_id("lottplants:pipeweed_wild")
  41. local c_plant2 = minetest.get_content_id("lottplants:barley_wild")
  42. local c_plant3 = minetest.get_content_id("lottplants:corn_wild")
  43. local c_plant4 = minetest.get_content_id("lottplants:potato_wild")
  44. local c_plant5 = minetest.get_content_id("lottplants:mushroom_wild")
  45. local c_plant6 = minetest.get_content_id("lottplants:berries_wild")
  46. local c_plant7 = minetest.get_content_id("lottplants:turnips_wild")
  47. local c_plant8 = minetest.get_content_id("lottplants:tomatoes_wild")
  48. local c_plant9 = minetest.get_content_id("lottplants:cabbage_wild")
  49. local rand = math.random(9)
  50. if rand == 1 then
  51. data[vi] = c_plant1
  52. p2data[vi] = 34
  53. elseif rand == 2 then
  54. data[vi] = c_plant2
  55. p2data[vi] = 3
  56. elseif rand == 3 then
  57. data[vi] = c_plant3
  58. p2data[vi] = 3
  59. elseif rand == 4 then
  60. data[vi] = c_plant4
  61. p2data[vi] = 40
  62. elseif rand == 5 then
  63. data[vi] = c_plant5
  64. p2data[vi] = 9
  65. elseif rand == 6 then
  66. data[vi] = c_plant6
  67. p2data[vi] = 34
  68. elseif rand == 7 then
  69. data[vi] = c_plant7
  70. p2data[vi] = 40
  71. elseif rand == 8 then
  72. data[vi] = c_plant8
  73. p2data[vi] = 10
  74. else
  75. data[vi] = c_plant9
  76. end
  77. end
  78. function lottmapgen_ithildinplants(data, vi, p2data)
  79. local c_iplant1 = minetest.get_content_id("lottplants:asphodel")
  80. local c_iplant2 = minetest.get_content_id("lottplants:anemones")
  81. local c_iplant3 = minetest.get_content_id("lottplants:eglantive")
  82. local c_iplant4 = minetest.get_content_id("lottplants:iris")
  83. local rand = math.random(4)
  84. if rand == 1 then
  85. data[vi] = c_iplant1
  86. elseif rand == 2 then
  87. data[vi] = c_iplant2
  88. elseif rand == 3 then
  89. data[vi] = c_iplant3
  90. else
  91. data[vi] = c_iplant4
  92. end
  93. p2data[vi] = 40
  94. end
  95. function lottmapgen_lorienplants(data, vi, p2data)
  96. local c_lplant1 = minetest.get_content_id("lottplants:elanor")
  97. local c_lplant2 = minetest.get_content_id("lottplants:lissuin")
  98. local c_lplant3 = minetest.get_content_id("lottplants:niphredil")
  99. local rand = math.random(3)
  100. if rand == 1 then
  101. data[vi] = c_lplant1
  102. p2data[vi] = 10
  103. elseif rand == 2 then
  104. data[vi] = c_lplant2
  105. p2data[vi] = 41
  106. else
  107. data[vi] = c_lplant3
  108. p2data[vi] = 8
  109. end
  110. end
  111. function lottmapgen_papyrus(x, y, z, area, data, p2data)
  112. local c_papyrus = minetest.get_content_id("default:papyrus")
  113. local ph = math.random(0, 3)
  114. for j = 0, ph do
  115. local vip = area:index(x, y + j, z)
  116. data[vip] = c_papyrus
  117. p2data[vip] = 3
  118. end
  119. end
  120. function lottmapgen_farmingrareplants(data, vi, p2data)
  121. local c_rplant1 = minetest.get_content_id("lottplants:athelas")
  122. local c_rplant2 = minetest.get_content_id("lottplants:melon_wild")
  123. local rand = math.random(2)
  124. if rand == 1 then
  125. data[vi] = c_rplant1
  126. p2data[vi] = 2
  127. else
  128. data[vi] = c_rplant2
  129. end
  130. end
  131. function lottmapgen_burnedtree(x, y, z, area, data)
  132. local c_tree = minetest.get_content_id("default:tree")
  133. for j = -2, 4 do
  134. for i = -2, 2 do
  135. if i == 0 or j == 2 or (j == 3 and math.abs(i) == 2) then
  136. local vic = area:index(x + i, y + j, z)
  137. data[vic] = c_tree
  138. end
  139. end
  140. end
  141. end
  142. function lottmapgen_appletree(x, y, z, area, data)
  143. local c_tree = minetest.get_content_id("default:tree")
  144. local c_apple = minetest.get_content_id("default:apple")
  145. local c_leaves = minetest.get_content_id("default:leaves")
  146. for j = -2, 4 do
  147. if j >= 1 then
  148. for i = -2, 2 do
  149. for k = -2, 2 do
  150. local vil = area:index(x + i, y + j + 1, z + k)
  151. if math.random(48) == 2 then
  152. data[vil] = c_apple
  153. elseif math.random(3) ~= 2 then
  154. data[vil] = c_leaves
  155. end
  156. end
  157. end
  158. end
  159. local vit = area:index(x, y + j, z)
  160. data[vit] = c_tree
  161. end
  162. end
  163. function lottmapgen_plumtree(x, y, z, area, data)
  164. local c_tree = minetest.get_content_id("default:tree")
  165. local c_plum = minetest.get_content_id("lottplants:plum")
  166. local c_plumleaf = minetest.get_content_id("lottplants:plumleaf")
  167. for j = -2, 4 do
  168. if j >= 1 then
  169. for i = -2, 2 do
  170. for k = -2, 2 do
  171. local vil = area:index(x + i, y + j + 1, z + k)
  172. if math.random(48) == 2 then
  173. data[vil] = c_plum
  174. elseif math.random(3) ~= 2 then
  175. data[vil] = c_plumleaf
  176. end
  177. end
  178. end
  179. end
  180. local vit = area:index(x, y + j, z)
  181. data[vit] = c_tree
  182. end
  183. end
  184. function lottmapgen_rowantree(x, y, z, area, data)
  185. local c_tree = minetest.get_content_id("default:tree")
  186. local c_rowanberry = minetest.get_content_id("lottplants:rowanberry")
  187. local c_rowanleaf = minetest.get_content_id("lottplants:rowanleaf")
  188. for j = -2, 4 do
  189. if j >= 1 then
  190. for i = -2, 2 do
  191. for k = -2, 2 do
  192. local vil = area:index(x + i, y + j + 1, z + k)
  193. if math.random(48) == 2 then
  194. data[vil] = c_rowanberry
  195. elseif math.random(3) ~= 2 then
  196. data[vil] = c_rowanleaf
  197. end
  198. end
  199. end
  200. end
  201. local vit = area:index(x, y + j, z)
  202. data[vit] = c_tree
  203. end
  204. end
  205. function lottmapgen_culumaldatree(x, y, z, area, data)
  206. local c_tree = minetest.get_content_id("default:tree")
  207. local c_yellowflowers = minetest.get_content_id("lottplants:yellowflowers")
  208. local c_culumaldaleaf = minetest.get_content_id("lottplants:culumaldaleaf")
  209. for j = -2, 4 do
  210. if j >= 1 then
  211. for i = -2, 2 do
  212. for k = -2, 2 do
  213. local vil = area:index(x + i, y + j + 1, z + k)
  214. if math.random(48) == 2 then
  215. data[vil] = c_yellowflowers
  216. elseif math.random(3) ~= 2 then
  217. data[vil] = c_culumaldaleaf
  218. end
  219. end
  220. end
  221. end
  222. local vit = area:index(x, y + j, z)
  223. data[vit] = c_tree
  224. end
  225. end
  226. function lottmapgen_yavannamiretree(x, y, z, area, data)
  227. local c_tree = minetest.get_content_id("default:tree")
  228. local c_yavannamirefruit = minetest.get_content_id("lottplants:yavannamirefruit")
  229. local c_yavannamireleaf = minetest.get_content_id("lottplants:yavannamireleaf")
  230. for j = -2, 4 do
  231. if j >= 1 then
  232. for i = -2, 2 do
  233. for k = -2, 2 do
  234. local vil = area:index(x + i, y + j + 1, z + k)
  235. if math.random(48) == 2 then
  236. data[vil] = c_yavannamirefruit
  237. elseif math.random(3) ~= 2 then
  238. data[vil] = c_yavannamireleaf
  239. end
  240. end
  241. end
  242. end
  243. local vit = area:index(x, y + j, z)
  244. data[vit] = c_tree
  245. end
  246. end
  247. function lottmapgen_defaulttree(x, y, z, area, data)
  248. local c_tree = minetest.get_content_id("default:tree")
  249. local c_leaves = minetest.get_content_id("default:leaves")
  250. for j = -2, 4 do
  251. if j >= 1 then
  252. for i = -2, 2 do
  253. for k = -2, 2 do
  254. local vil = area:index(x + i, y + j + 1, z + k)
  255. if math.random(48) == 2 then
  256. data[vil] = c_leaves
  257. elseif math.random(3) ~= 2 then
  258. data[vil] = c_leaves
  259. end
  260. end
  261. end
  262. end
  263. local vit = area:index(x, y + j, z)
  264. data[vit] = c_tree
  265. end
  266. end
  267. function lottmapgen_aldertree(x, y, z, area, data)
  268. local c_aldertree = minetest.get_content_id("lottplants:aldertree")
  269. local c_alderleaf = minetest.get_content_id("lottplants:alderleaf")
  270. for j = -2, 4 do
  271. if j >= 1 then
  272. for i = -2, 2 do
  273. for k = -2, 2 do
  274. local vil = area:index(x + i, y + j + 1, z + k)
  275. if math.random(48) == 2 then
  276. data[vil] = c_alderleaf
  277. elseif math.random(3) ~= 2 then
  278. data[vil] = c_alderleaf
  279. end
  280. end
  281. end
  282. end
  283. local vit = area:index(x, y + j, z)
  284. data[vit] = c_aldertree
  285. end
  286. end
  287. function lottmapgen_lebethrontree(x, y, z, area, data)
  288. local c_lebethrontree = minetest.get_content_id("lottplants:lebethrontree")
  289. local c_lebethronleaf = minetest.get_content_id("lottplants:lebethronleaf")
  290. for j = -2, 4 do
  291. if j >= 1 then
  292. for i = -2, 2 do
  293. for k = -2, 2 do
  294. local vil = area:index(x + i, y + j + 1, z + k)
  295. if math.random(48) == 2 then
  296. data[vil] = c_lebethronleaf
  297. elseif math.random(3) ~= 2 then
  298. data[vil] = c_lebethronleaf
  299. end
  300. end
  301. end
  302. end
  303. local vit = area:index(x, y + j, z)
  304. data[vit] = c_lebethrontree
  305. end
  306. end
  307. function lottmapgen_whitetree(x, y, z, area, data)
  308. local c_tree = minetest.get_content_id("default:tree")
  309. local c_whiteleaf = minetest.get_content_id("lottplants:whiteleaf")
  310. local t = 6 + math.random(2) -- trunk height
  311. for j = -2, t do
  312. if j == t or j == t - 2 or j == t - 4 then
  313. for i = -3, 3 do
  314. for k = -3, 3 do
  315. local vil = area:index(x + i, y + j + math.random(0, 1), z + k)
  316. if math.random(48) == 2 then
  317. data[vil] = c_whiteleaf
  318. elseif math.random(3) ~= 2 then
  319. data[vil] = c_whiteleaf
  320. end
  321. end
  322. end
  323. end
  324. if j == t - 1 then
  325. for i = -2, 2 do
  326. for k = -2, 2 do
  327. if i == -1 and k == 0 or i == 1 and k == 0
  328. or k == 1 and i == 0 or k == -1 and i == 0
  329. or i == -2 and k == 0 or i == 2 and k == 0
  330. or k == 2 and i == 0 or k == -2 and i == 0 then
  331. local vil = area:index(x + i, y + j + 1, z + k)
  332. data[vil] = c_tree
  333. end
  334. end
  335. end
  336. end
  337. local vit = area:index(x, y + j, z)
  338. data[vit] = c_tree
  339. end
  340. end
  341. function lottmapgen_birchtree(x, y, z, area, data)
  342. local c_birchtree = minetest.get_content_id("lottplants:birchtree")
  343. local c_birchleaf = minetest.get_content_id("lottplants:birchleaf")
  344. for j = -5, 12 do
  345. if j == 8 or j == 11 then
  346. for i = -2, 2 do
  347. for k = -2, 2 do
  348. local vil = area:index(x + i, y + j + math.random(0, 1), z + k)
  349. if math.random(5) ~= 2 then
  350. data[vil] = c_birchleaf
  351. end
  352. end
  353. end
  354. end
  355. local vit = area:index(x, y + j, z)
  356. data[vit] = c_birchtree
  357. end
  358. end
  359. function lottmapgen_elmtree(x, y, z, area, data)
  360. local c_tree = minetest.get_content_id("default:tree")
  361. local c_elmleaf = minetest.get_content_id("lottplants:elmleaf")
  362. for j = -5, 25 do
  363. if j == 11 or j == 18 or j == 24 then
  364. for i = -2, 2 do
  365. for k = -2, 2 do
  366. local vil = area:index(x + i, y + j + math.random(0, 1), z + k)
  367. if math.random(5) ~= 2 then
  368. data[vil] = c_elmleaf
  369. end
  370. end
  371. end
  372. end
  373. local vit = area:index(x, y + j, z)
  374. data[vit] = c_tree
  375. end
  376. end
  377. function lottmapgen_mallornsmalltree(x, y, z, area, data)
  378. local c_mallorntree = minetest.get_content_id("lottplants:mallorntree")
  379. local c_mallornleaf = minetest.get_content_id("lottplants:mallornleaf")
  380. for j = -5, 15 do
  381. if j == 11 or j == 15 then
  382. for i = -2, 2 do
  383. for k = -2, 2 do
  384. local vil = area:index(x + i, y + j + math.random(0, 1), z + k)
  385. if math.random(5) ~= 2 then
  386. data[vil] = c_mallornleaf
  387. end
  388. end
  389. end
  390. end
  391. local vit = area:index(x, y + j, z)
  392. data[vit] = c_mallorntree
  393. end
  394. end
  395. function lottmapgen_young_mallorn(x, y, z, area, data)
  396. local c_youngmallorn = minetest.get_content_id("lottplants:mallorntree_young")
  397. local c_mallornleaf = minetest.get_content_id("lottplants:mallornleaf")
  398. local t = 6 + math.random(1) -- trunk height
  399. for j = 0, t do
  400. if j == t or j == t - 2 then
  401. for i = -1, 1 do
  402. for k = -1, 1 do
  403. local vil = area:index(x + i, y + j + math.random(0, 1), z + k)
  404. local absi = math.abs(i)
  405. local absk = math.abs(k)
  406. if math.random() > (absi + absk) / 24 then
  407. data[vil] = c_mallornleaf
  408. end
  409. end
  410. end
  411. end
  412. local vit = area:index(x, y + j, z)
  413. data[vit] = c_youngmallorn
  414. end
  415. end
  416. function lottmapgen_jungletree(x, y, z, area, data)
  417. local c_tree = minetest.get_content_id("default:tree")
  418. local c_leaves = minetest.get_content_id("default:leaves")
  419. for j = -2, 5 do
  420. if j == 4 then
  421. for i = -2, 2 do
  422. for k = -2, 2 do
  423. local vil = area:index(x + i, y + j + math.random(0, 1), z + k)
  424. if math.random(5) ~= 2 then
  425. data[vil] = c_leaves
  426. end
  427. end
  428. end
  429. end
  430. local vit = area:index(x, y + j, z)
  431. data[vit] = c_tree
  432. end
  433. end
  434. function lottmapgen_jungletree2(x, y, z, area, data)
  435. local c_tree = minetest.get_content_id("default:jungletree")
  436. local c_leaves = minetest.get_content_id("lottplants:mirkleaf")
  437. for j = -3, 7 do
  438. if j == 6 then
  439. for i = -4, 4 do
  440. for k = -4, 4 do
  441. if math.random(20) ~= 10 then
  442. local vil = area:index(x + i, y + j + math.random(1, 2), z + k)
  443. data[vil] = c_leaves
  444. end
  445. end
  446. end
  447. for i = -1, 1 do
  448. for k = -1, 1 do
  449. if math.abs(i) + math.abs(k) == 2 then
  450. local vit = area:index(x + i, y + j, z + k)
  451. data[vit] = c_tree
  452. end
  453. end
  454. end
  455. elseif j == 7 then
  456. for i = -2, 2, 4 do
  457. for k = -2, 2, 4 do
  458. local vit = area:index(x + i, y + j, z + k)
  459. data[vit] = c_tree
  460. end
  461. end
  462. else
  463. local vit = area:index(x, y + j, z)
  464. data[vit] = c_tree
  465. end
  466. end
  467. end
  468. function lottmapgen_pinetree(x, y, z, area, data)
  469. local c_pinetree = minetest.get_content_id("lottplants:pinetree")
  470. local c_pineleaf = minetest.get_content_id("lottplants:pineleaf")
  471. local c_snow = minetest.get_content_id("default:snow")
  472. for j = -4, 13 do
  473. if j == 3 or j == 6 or j == 9 or j == 12 then
  474. for i = -2, 2 do
  475. for k = -2, 2 do
  476. if math.abs(i) == 2 or math.abs(k) == 2 then
  477. if math.random(5) ~= 2 then
  478. local vil = area:index(x + i, y + j, z + k)
  479. data[vil] = c_pineleaf
  480. local vila = area:index(x + i, y + j + 1, z + k)
  481. data[vila] = c_snow
  482. end
  483. end
  484. end
  485. end
  486. elseif j == 4 or j == 7 or j == 10 or j == 13 then
  487. for i = -1, 1 do
  488. for k = -1, 1 do
  489. if not (i == 0 and j == 0) then
  490. if math.random(7) ~= 2 then
  491. local vil = area:index(x + i, y + j, z + k)
  492. data[vil] = c_pineleaf
  493. local vila = area:index(x + i, y + j + 1, z + k)
  494. data[vila] = c_snow
  495. end
  496. end
  497. end
  498. end
  499. end
  500. local vit = area:index(x, y + j, z)
  501. data[vit] = c_pinetree
  502. end
  503. local vil = area:index(x, y + 14, z)
  504. local vila = area:index(x, y + 15, z)
  505. local vilaa = area:index(x, y + 16, z)
  506. data[vil] = c_pineleaf
  507. data[vila] = c_pineleaf
  508. data[vilaa] = c_snow
  509. end
  510. function lottmapgen_firtree(x, y, z, area, data)
  511. local c_pinetree = minetest.get_content_id("lottplants:pinetree")
  512. local c_firleaf = minetest.get_content_id("lottplants:firleaf")
  513. local c_snow = minetest.get_content_id("default:snow")
  514. for j = -4, 13 do
  515. if j == 3 or j == 6 or j == 9 or j == 12 then
  516. for i = -2, 2 do
  517. for k = -2, 2 do
  518. if math.abs(i) == 2 or math.abs(k) == 2 then
  519. if math.random(5) ~= 2 then
  520. local vil = area:index(x + i, y + j, z + k)
  521. data[vil] = c_firleaf
  522. local vila = area:index(x + i, y + j + 1, z + k)
  523. data[vila] = c_snow
  524. end
  525. end
  526. end
  527. end
  528. elseif j == 4 or j == 7 or j == 10 or j == 13 then
  529. for i = -1, 1 do
  530. for k = -1, 1 do
  531. if not (i == 0 and j == 0) then
  532. if math.random(7) ~= 2 then
  533. local vil = area:index(x + i, y + j, z + k)
  534. data[vil] = c_firleaf
  535. local vila = area:index(x + i, y + j + 1, z + k)
  536. data[vila] = c_snow
  537. end
  538. end
  539. end
  540. end
  541. end
  542. local vit = area:index(x, y + j, z)
  543. data[vit] = c_pinetree
  544. end
  545. local vil = area:index(x, y + 14, z)
  546. local vila = area:index(x, y + 15, z)
  547. local vilaa = area:index(x, y + 16, z)
  548. data[vil] = c_firleaf
  549. data[vila] = c_firleaf
  550. data[vilaa] = c_snow
  551. end
  552. function lottmapgen_oaktree(x, y, z, area, data)
  553. local c_tree = minetest.get_content_id("default:tree")
  554. local c_leaves = minetest.get_content_id("default:leaves")
  555. for j = -4, 13 do
  556. if j == 3 or j == 6 or j == 9 or j == 12 then
  557. for i = -2, 2 do
  558. for k = -2, 2 do
  559. if math.abs(i) == 2 or math.abs(k) == 2 then
  560. if math.random(5) ~= 2 then
  561. local vil = area:index(x + i, y + j, z + k)
  562. data[vil] = c_leaves
  563. end
  564. end
  565. end
  566. end
  567. elseif j == 4 or j == 7 or j == 10 or j == 13 then
  568. for i = -1, 1 do
  569. for k = -1, 1 do
  570. if not (i == 0 and j == 0) then
  571. if math.random(7) ~= 2 then
  572. local vil = area:index(x + i, y + j, z + k)
  573. data[vil] = c_leaves
  574. end
  575. end
  576. end
  577. end
  578. end
  579. local vit = area:index(x, y + j, z)
  580. data[vit] = c_tree
  581. end
  582. local vil = area:index(x, y + 14, z)
  583. local vila = area:index(x, y + 15, z)
  584. data[vil] = c_leaves
  585. data[vila] = c_leaves
  586. end
  587. -- Trees Big
  588. function lottmapgen_mallorntree(x, y, z, area, data)
  589. local c_maltree = minetest.get_content_id("lottplants:mallorntree")
  590. local c_malleaf = minetest.get_content_id("lottplants:mallornleaf")
  591. local top = math.random(25, 30)
  592. local mid = math.floor(top/2)
  593. for j = math.random(-4, -2), top do
  594. if j == top or j == top - 1 or j == top + 1
  595. or j == top - 2 or j == top - 3 then
  596. for i = -3, 2 do -- leaves
  597. for k = -3, 2 do
  598. local vi = area:index(x + i, y + j, z + k)
  599. if math.random(5) ~= 2 then
  600. data[vi] = c_malleaf
  601. end
  602. end
  603. end
  604. for i = -1, 4 do -- leaves
  605. for k = -1, 4 do
  606. local vi = area:index(x + i, y + j, z + k)
  607. if math.random(5) ~= 2 then
  608. data[vi] = c_malleaf
  609. end
  610. end
  611. end
  612. elseif j == mid + 5 or j == mid + 4 then
  613. for i = -1, 2 do -- leaves
  614. for k = -1, 2 do
  615. local vi = area:index(x + i, y + j, z + k)
  616. if math.random(5) ~= 2 then
  617. data[vi] = c_malleaf
  618. end
  619. end
  620. end
  621. elseif j == mid - 3 or j == mid - 2 or j == mid - 1 then
  622. for i = -2, 3 do -- leaves
  623. for k = -2, 3 do
  624. local vi = area:index(x + i, y + j, z + k)
  625. if math.random(5) ~= 2 then
  626. data[vi] = c_malleaf
  627. end
  628. end
  629. end
  630. end
  631. if j <= math.random(-1, 0) then -- roots
  632. for i = -2, 3 do
  633. for k = -2, 3 do
  634. if i == 0 and k == -1 or i == -1 and k == 1 or
  635. i == 1 and k == 2 or i == 2 and k == 0 then
  636. local vi = area:index(x + i, y + j, z + k)
  637. data[vi] = c_maltree
  638. end
  639. end
  640. end
  641. elseif j == top - 2 then
  642. for i = -2, 3 do
  643. for k = -2, 3 do
  644. if i == 0 and k == -1 or i == -1 and k == 1 or
  645. i == 1 and k == 2 or i == 2 and k == 0 then
  646. local vi = area:index(x + i, y + j, z + k)
  647. data[vi] = c_maltree
  648. elseif i == 0 and k == -2 or i == -2 and k == 1
  649. or i == 1 and k == 3 or i == 3 and k == 0 then
  650. local vi = area:index(x + i, y + j, z + k)
  651. data[vi] = c_maltree
  652. end
  653. end
  654. end
  655. end
  656. if j >= -1 and j <= top - 1 then -- trunk
  657. for i = 0, 1 do
  658. for k = 0, 1 do
  659. local vi = area:index(x + i, y + j, z + k)
  660. data[vi] = c_maltree
  661. end
  662. end
  663. end
  664. end
  665. end
  666. function lottmapgen_beechtree(x, y, z, area, data)
  667. local c_tree = minetest.get_content_id("default:tree")
  668. local c_beechleaf = minetest.get_content_id("lottplants:beechleaf")
  669. local t = 10 + math.random(3) -- trunk height
  670. for i = -2, 2 do
  671. for k = -2, 2 do
  672. local absi = math.abs(i)
  673. local absk = math.abs(k)
  674. if absi >= absk then
  675. j = t - absi
  676. else
  677. j = t - absk
  678. end
  679. if math.random() > (absi + absk) / 24 then
  680. data[area:index(x+i, y+j+7, z+k)] = c_beechleaf
  681. data[area:index(x+i, y+j+4, z+k)] = c_beechleaf
  682. data[area:index(x+i+2, y+j+4, z+k)] = c_beechleaf
  683. data[area:index(x+i-2, y+j+4, z+k)] = c_beechleaf
  684. data[area:index(x+i, y+j+4, z+k+2)] = c_beechleaf
  685. data[area:index(x+i, y+j+4, z+k-2)] = c_beechleaf
  686. data[area:index(x+i, y+j+1, z+k)] = c_beechleaf
  687. data[area:index(x+i+3, y+j+1, z+k)] = c_beechleaf
  688. data[area:index(x+i-3, y+j+1, z+k)] = c_beechleaf
  689. data[area:index(x+i, y+j+1, z+k+3)] = c_beechleaf
  690. data[area:index(x+i, y+j+1, z+k-3)] = c_beechleaf
  691. data[area:index(x+i, y+j-2, z+k)] = c_beechleaf
  692. data[area:index(x+i+3, y+j-2, z+k)] = c_beechleaf
  693. data[area:index(x+i-3, y+j-2, z+k)] = c_beechleaf
  694. data[area:index(x+i, y+j-2, z+k+3)] = c_beechleaf
  695. data[area:index(x+i, y+j-2, z+k-3)] = c_beechleaf
  696. data[area:index(x+i, y+j-5, z+k)] = c_beechleaf
  697. data[area:index(x+i+4, y+j-5, z+k)] = c_beechleaf
  698. data[area:index(x+i-4, y+j-5, z+k)] = c_beechleaf
  699. data[area:index(x+i, y+j-5, z+k+4)] = c_beechleaf
  700. data[area:index(x+i, y+j-5, z+k-4)] = c_beechleaf
  701. data[area:index(x+i, y+j-8, z+k)] = c_beechleaf
  702. data[area:index(x+i+4, y+j-8, z+k)] = c_beechleaf
  703. data[area:index(x+i-4, y+j-8, z+k)] = c_beechleaf
  704. data[area:index(x+i, y+j-8, z+k+4)] = c_beechleaf
  705. data[area:index(x+i, y+j-8, z+k-4)] = c_beechleaf
  706. end
  707. end
  708. end
  709. for j = -3, t do
  710. data[area:index(x, y+j, z)] = c_tree
  711. end
  712. end
  713. function lottmapgen_mirktree(x, y, z, area, data)
  714. local c_juntree = minetest.get_content_id("default:jungletree")
  715. local c_junleaf = minetest.get_content_id("lottplants:mirkleaf")
  716. local top = math.random(6, 8)
  717. for j = math.random(-4, -2), top do
  718. if j == top or j == top - 1 or j == top + 1 or j == top - 2 then
  719. for i = -3, 4 do -- leaves
  720. for k = -3, 4 do
  721. local vi = area:index(x + i, y + j, z + k)
  722. if math.random(5) ~= 2 then
  723. data[vi] = c_junleaf
  724. end
  725. end
  726. end
  727. elseif j <= math.random(-1, 0) then -- roots
  728. for i = -1, 2, 3 do
  729. for k = -1, 2, 3 do
  730. local vi = area:index(x + i, y + j, z + k)
  731. data[vi] = c_juntree
  732. end
  733. end
  734. elseif j == top - 2 then
  735. for i = -2, 3 do
  736. for k = -2, 3 do
  737. if i == 0 and k == -1 or i == -1 and k == 1 or
  738. i == 1 and k == 2 or i == 2 and k == 0 then
  739. local vi = area:index(x + i, y + j, z + k)
  740. data[vi] = c_juntree
  741. elseif i == 0 and k == -2 or i == -2 and k == 1
  742. or i == 1 and k == 3 or i == 3 and k == 0 then
  743. local vi = area:index(x + i, y + j, z + k)
  744. data[vi] = c_juntree
  745. end
  746. end
  747. end
  748. end
  749. if j >= -1 and j <= top - 2 then -- trunk
  750. for i = 0, 1 do
  751. for k = 0, 1 do
  752. local vi = area:index(x + i, y + j, z + k)
  753. data[vi] = c_juntree
  754. end
  755. end
  756. end
  757. end
  758. end
  759. function lottmapgen_elf_workshop(x, y, z, area, data, p2data)
  760. local c_stonebrick = minetest.get_content_id("default:stonebrick")
  761. local c_cracked_stonebrick = minetest.get_content_id("default:cracked_stonebrick")
  762. local c_marblebrick = minetest.get_content_id("lottblocks:marble_brick")
  763. local c_elftorchwall = minetest.get_content_id("lottblocks:elf_torch_wall")
  764. local c_furnace = minetest.get_content_id("lottmapgen:furnace_spawner")
  765. local c_dual_furnace = minetest.get_content_id("lottmapgen:dual_furnace_spawner")
  766. local c_ringsilver_furnace = minetest.get_content_id("lottmapgen:ringsilver_furnace_spawner")
  767. local c_water = minetest.get_content_id("default:water_source")
  768. local c_ringchest = minetest.get_content_id("lottmapgen:ring_chest_spawner")
  769. local c_table = minetest.get_content_id("lottblocks:mallorn_table")
  770. local c_chair = minetest.get_content_id("lottblocks:mallorn_chair")
  771. local c_bedb = minetest.get_content_id("lottblocks:bed_bottom_blue")
  772. local c_bedt = minetest.get_content_id("lottblocks:bed_top_blue")
  773. local c_malpillar = minetest.get_content_id("lottblocks:mallorn_pillar")
  774. local c_air = minetest.get_content_id("air")
  775. for j = 0, 6 do
  776. if j == 0 then
  777. for i = 0, 7 do
  778. for k = 0, 9 do
  779. local vi = area:index(x + i, y + j, z + k)
  780. if i == 1 and k == 6 then
  781. data[vi] = c_water
  782. else
  783. data[vi] = c_marblebrick
  784. end
  785. end
  786. end
  787. elseif j == 6 then
  788. for i = 0, 7 do
  789. for k = 0, 9 do
  790. local vi = area:index(x + i, y + j, z + k)
  791. if math.random(1, 3) == 2 then
  792. data[vi] = c_cracked_stonebrick
  793. else
  794. data[vi] = c_stonebrick
  795. end
  796. end
  797. end
  798. else
  799. for i = 0, 7 do
  800. for k = 0, 9 do
  801. local vi = area:index(x + i, y + j, z + k)
  802. if i == 0 or i == 7 or k == 0 or k == 9 then
  803. if math.random(1, 3) == 2 then
  804. data[vi] = c_cracked_stonebrick
  805. else
  806. data[vi] = c_stonebrick
  807. end
  808. elseif (i == 1 and k == 1) or (i == 6 and k == 1) or
  809. (i == 1 and k == 8) or (i == 6 and k == 8) then
  810. data[vi] = c_malpillar
  811. elseif (i == 1 and j == 4 and k == 2) or
  812. (i == 6 and j == 4 and k == 2) or
  813. (i == 1 and j == 4 and k == 7) or
  814. (i == 6 and j == 4 and k == 7) then
  815. data[vi] = c_elftorchwall
  816. if i == 6 then
  817. p2data[vi] = 2
  818. else
  819. p2data[vi] = 3
  820. end
  821. elseif i == 1 and j == 1 and k == 2 then
  822. data[vi] = c_furnace
  823. p2data[vi] = 3
  824. elseif i == 1 and j == 1 and (k == 3 or k == 4) then
  825. data[vi] = c_dual_furnace
  826. p2data[vi] = 3
  827. elseif i == 1 and j == 1 and k == 5 then
  828. data[vi] = c_ringsilver_furnace
  829. p2data[vi] = 3
  830. elseif i == 1 and j == 1 and k == 7 then
  831. data[vi] = c_ringchest
  832. p2data[vi] = 3
  833. elseif i == 6 and j == 1 and k == 3 and math.random(1, 2) == 1 then
  834. data[vi] = c_table
  835. elseif i == 6 and j == 1 and (k == 2 or k == 4) and math.random(1, 3) == 1 then
  836. data[vi] = c_chair
  837. if k == 2 then
  838. p2data[vi] = 2
  839. end
  840. elseif i == 5 and j == 1 and k == 8 and math.random(1,4) == 2 then
  841. data[vi] = c_bedt
  842. p2data[vi] = 1
  843. vi = area:index(x + i - 1, y + j, z + k)
  844. data[vi] = c_bedb
  845. p2data[vi] = 1
  846. else
  847. data[vi] = c_air
  848. end
  849. end
  850. end
  851. end
  852. end
  853. end
  854. function lottmapgen_mithrilore(x, y, z, area, data)
  855. local c_ore = minetest.get_content_id("lottores:mithril_ore")
  856. local c_stone = minetest.get_content_id("default:stone")
  857. for j = -1, 0 do
  858. for i = -1, 0 do
  859. for k = -1, 0 do
  860. local vil = area:index(x + i, y + j, z + k)
  861. if math.random(3) == 1 then
  862. data[vil] = c_stone
  863. else
  864. data[vil] = c_ore
  865. end
  866. end
  867. end
  868. end
  869. end
  870. function lottmapgen_meseore(x, y, z, area, data)
  871. local c_ore = minetest.get_content_id("default:stone_with_mese")
  872. local c_stone = minetest.get_content_id("default:stone")
  873. for j = -1, 0 do
  874. for i = -1, 0 do
  875. for k = -1, 0 do
  876. local vil = area:index(x + i, y + j, z + k)
  877. if math.random(3) == 1 then
  878. data[vil] = c_stone
  879. else
  880. data[vil] = c_ore
  881. end
  882. end
  883. end
  884. end
  885. end
  886. function lottmapgen_orcore(x, y, z, area, data)
  887. local c_ore = minetest.get_content_id("lottores:orc_ore")
  888. local c_stone = minetest.get_content_id("default:stone")
  889. for j = -1, 0 do
  890. for i = -1, 0 do
  891. for k = -1, 0 do
  892. local vil = area:index(x + i, y + j, z + k)
  893. if math.random(10) == 1 then
  894. data[vil] = c_stone
  895. else
  896. data[vil] = c_ore
  897. end
  898. end
  899. end
  900. end
  901. end
  902. function lottmapgen_biomes(biome, n_temp, n_humid, n_ran, LOTET, LOHUT, LORAN, HITET, HIHUT, HIRAN)
  903. if n_temp < LOTET then
  904. if n_humid < LOHUT then
  905. return 1 -- (Angmar)
  906. elseif n_humid > HIHUT then
  907. return 3 -- (Trollshaws)
  908. else
  909. return 2 -- (Snowplains)
  910. end
  911. elseif n_temp > HITET then
  912. if n_humid < LOHUT then
  913. return 7 -- (Lorien)
  914. elseif n_humid > HIHUT then
  915. return 9 -- (Fangorn)
  916. elseif n_ran < LORAN then
  917. return 10 -- (Mirkwood)
  918. elseif n_ran > HIRAN then
  919. return 11 -- (Iron Hills)
  920. else
  921. return 4 -- (Dunlands)
  922. end
  923. else
  924. if n_humid < LOHUT then
  925. return 8 -- (Mordor)
  926. elseif n_humid > HIHUT then
  927. return 6 -- (Ithilien)
  928. elseif n_ran < LORAN then
  929. return 13 -- (Shire)
  930. elseif n_ran > HIRAN then
  931. return 12 -- (Rohan)
  932. else
  933. return 5 -- (Gondor)
  934. end
  935. end
  936. end