mapgen.lua 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
  1. local moreores = minetest.get_modpath("moreores")
  2. local nethermod = minetest.get_modpath("nether")
  3. local is_50 = nssb.is_50
  4. nssb.mymapgenis = tonumber(minetest.settings:get("mymapgenis")) or 7
  5. if nssb.mymapgenis ~= 6 and nssb.mymapgenis ~= 7 then
  6. nssb.mymapgenis = 7
  7. end
  8. -- mapgen limits check from minetest
  9. local mapgen_limit = tonumber(minetest.settings:get("mapgen_limit")) or 31000
  10. -- get generation level from settings
  11. local level = tonumber(minetest.settings:get("nssb.morlendor_level")) or -30000
  12. -- schematics generation
  13. local posplace = {x = 0, y = level - 93, z = 0}
  14. local posmemory = {x = 0, y = level - 92, z = 0}
  15. local postest = {x = 5, y = level - 91, z = 6}
  16. -- ore type generation depending on minetest version
  17. local oretype_morlan_layer
  18. if is_50 then oretype_morlan_layer = "stratum" else oretype_morlan_layer = "scatter" end
  19. -- mapgen limit must be at least enought before any check
  20. if mapgen_limit < 400 then error("[nssb] the map limit is too low, there's no space for morlendor") end
  21. -- morlendor must be inside the limits, but not almost the limit of the world, and must be almost 320 levels
  22. level_amount_and_limit = math.abs(mapgen_limit) - math.abs(level)
  23. while level_amount_and_limit <= 320 do
  24. level = (math.abs(level) - math.abs(level_amount_and_limit) - 1) * -1
  25. level_amount_and_limit = math.abs(mapgen_limit) - math.abs(level)
  26. minetest.log("error", "[nssb] incompatible morlendor level, autosetting: ".. level)
  27. end
  28. -- detection of nether deep floor, mordenlor must be below more than player things, cos has industructible layer
  29. if nethermod then
  30. local nether_df = math.abs(tonumber(minetest.settings:get("nether_depth_ymax")) or -11000)
  31. if ( math.abs(nether_df) >= math.abs(level) + 1000 ) then
  32. error("[nssb] morlendor level conflicts with nether, unable to fix, check your settings")
  33. end
  34. end
  35. function nssb_register_buildings(
  36. build, -- name of the schematic
  37. rand, -- 1/rand is the probability of the spawning of the schematic if the place found is acceptable
  38. posschem, -- the block on which the schematic need to be to spawn
  39. down, -- useful in finding flat surfaces, down indetify the x and z coordinates of a block 1 under posschem
  40. downblock, -- the block that is necessary to find in down to place the schematic
  41. above, -- when you need to place the schem under something (water, air, jungleleaves...) above is the number of blocks above posschem
  42. aboveblock, -- the name of this block above above-times posschem
  43. radius, -- the radius in which the function search for the "near" block
  44. near, -- the block that is necessary to spawn the schem in the radius
  45. side, -- the mesure of the side of the schematic, it is necessary to put the dirt under it
  46. underground, -- if true the schematic need to spawn underground
  47. height, -- under this heigh the schematic can spawn. If nil the schematic can spawn everywhere underground
  48. ice, -- if true fill the space under the schem with ice and not with dirt as standard
  49. exact_height, -- exact_height=exact_eight under the surface in the correct place
  50. portal) -- is this schematic a portal for the morlendor?
  51. minetest.register_on_generated(function(minp, maxp, seed)
  52. if underground == false then
  53. local i, j, k
  54. local flag = 0
  55. local posd
  56. i = math.random(minp.x, maxp.x)
  57. k = math.random(minp.z, maxp.z)
  58. for j = minp.y, maxp.y do
  59. local pos1 = {x = i, y = j, z = k}
  60. local pos2 = {x = i + down, y = j - 1, z = k + down}
  61. local pos3 = {x = i, y = j + above, z = k}
  62. local n = minetest.get_node(pos1).name
  63. local u = minetest.get_node(pos2).name
  64. local d = minetest.get_node(pos3).name
  65. if downblock == nil then
  66. u = downblock
  67. end
  68. if aboveblock == nil then
  69. d = aboveblock
  70. end
  71. if n == posschem and u == downblock and d == aboveblock and flag == 0
  72. and math.random(1, rand) == 1 then
  73. if minetest.find_node_near(pos3, radius, near) then
  74. minetest.place_schematic(pos1, minetest.get_modpath("nssb")
  75. .. "/schems/" .. build .. ".mts", "0", {}, true)
  76. -- minetest.chat_send_all("Added schematic in "..(minetest.pos_to_string(pos1)))
  77. posd = pos1
  78. flag = 1
  79. end
  80. end
  81. end
  82. -- Puts dirt/ice under the schematic to fill the space under it
  83. if flag == 1 and side > 0 then
  84. for dx = 0, side do
  85. for dz = 0, side do
  86. local dy = posd.y - 1
  87. local f = {x = posd.x + dx, y = dy, z = posd.z + dz}
  88. local fg = minetest.get_node(f).name
  89. if ice == false then
  90. while fg == "air" do
  91. --minetest.set_node(f, {name = "default:dirt"})
  92. minetest.swap_node(f, {name = "default:dirt"})
  93. f.y = f.y - 1
  94. fg = minetest.get_node(f).name
  95. end
  96. else
  97. while fg == "air" do
  98. --minetest.set_node(f, {name = "default:ice"})
  99. minetest.swap_node(f, {name = "default:ice"})
  100. f.y = f.y - 1
  101. fg = minetest.get_node(f).name
  102. end
  103. end
  104. end
  105. end
  106. end
  107. if portal == true then
  108. --[[
  109. -- this is a portal for the morlendor
  110. if already_spawned == 0 then
  111. --already_spawned = 1
  112. local name = minetest.get_node(posplace).name
  113. minetest.chat_send_all("Non ancora creato. Nome: "..name)
  114. if name == "ignore" then
  115. local pmin, pmax = minetest.get_voxel_manip():read_from_map(
  116. vector.subtract(posplace, 80), vector.add(posplace, 80))
  117. name = minetest.get_node(posplace).name
  118. minetest.chat_send_all("name dopo read_from_map:.."..name)
  119. if name == "ignore" then
  120. minetest.emerge_area(vector.subtract(posplace, 80),
  121. vector.add(posplace, 80))
  122. name = minetest.get_node(posplace).name
  123. minetest.chat_send_all("name dopo emerge_area:.."..name)
  124. end
  125. minetest.after(25, function(posplace)
  126. name = minetest.get_node(posplace).name
  127. minetest.chat_send_all("name prima di place_schematic:.."..name)
  128. minetest.place_schematic(posplace,
  129. minetest.get_modpath("nssb")
  130. .. "/schems/memoportal.mts", "0", {}, true)
  131. -- minetest.place_schematic(posplace,
  132. minetest.get_modpath("nssb")
  133. .. "/schems/memoportal.mts", "0", {}, true)
  134. --minetest.chat_send_all("3")
  135. name = minetest.get_node(posplace).name
  136. minetest.chat_send_all("name dopo place_schematic:.."..name)
  137. end, posplace)
  138. end
  139. minetest.place_schematic(posplace, minetest.get_modpath("nssb")
  140. .. "/schems/memoportal.mts", "0", {}, true)
  141. end
  142. ]]--
  143. end
  144. else --underground == true
  145. if minp.y < 0 then
  146. -- minetest.chat_send_all("Posmin: " .. (minetest.pos_to_string(minp)).." Posmax: " .. (minetest.pos_to_string(maxp)))
  147. local i, jj, k, j
  148. local flag = 0
  149. i = math.random(minp.x, maxp.x)
  150. k = math.random(minp.z, maxp.z)
  151. jj = math.random(minp.y, maxp.y)
  152. if height ~= nil then
  153. if height > maxp.y then
  154. j = jj
  155. elseif height > minp.y and height < maxp.y then
  156. j = math.random(minp.y, height)
  157. else
  158. return
  159. end
  160. else
  161. if jj > 0 then
  162. j = math.random(minp.y, 0)
  163. end
  164. end
  165. local pos1 = {x = i, y = j, z = k}
  166. local n = minetest.get_node(pos1).name
  167. if minetest.find_node_near(pos1, radius, "default:lava_source")
  168. or flag == 1 then
  169. return
  170. else
  171. if n == posschem and math.random(1, rand) == 1 then
  172. minetest.place_schematic(pos1, minetest.get_modpath("nssb")
  173. .. "/schems/" .. build .. ".mts", "0", {}, true)
  174. flag = 1
  175. -- minetest.chat_send_all("Added schematic in "..(minetest.pos_to_string(pos1)))
  176. end
  177. end
  178. end
  179. end
  180. end)
  181. end
  182. if nssb.mymapgenis == 6 then
  183. nssb_register_buildings ("spiaggiagranchius", 2, "default:sand", 3, "default:sand", 2, "air", 3, "air", 0, false, nil, false, false, false)
  184. nssb_register_buildings ("acquagranchius", 3, "default:sand", 3, "default:sand", 12,"default:water_source", 3, "default:water_source", 0, false, nil, false, false, false)
  185. nssb_register_buildings ("ooteca", 6, "default:dirt_with_grass", 3, "default:dirt", 2, "air", 24, "default:tree", 8, false, nil, false, false, false)
  186. nssb_register_buildings ("minuscolaooteca", 6, "default:dirt_with_grass",3 , "default:dirt", 2, "air", 24, "default:tree", 2, false, nil, false, false, false)
  187. nssb_register_buildings ("piccolaooteca", 6, "default:dirt_with_grass", 2, "default:dirt", 2, "air", 24, "default:tree", 4, false, nil, false, false, false)
  188. nssb_register_buildings ("arcate", 8, "default:sand", 3, "default:sand", 13, "default:water_source", 3, "default:water_source",0, false, nil, false, false, false)
  189. nssb_register_buildings ("grandepiramide", 8, "default:dirt", 3, "default:dirt", 20, "default:water_source", 3, "default:water_source", 0, false, nil, false, false, false)
  190. nssb_register_buildings ("collina", 5, "default:dirt_with_grass", 3, "default:dirt", 2, "air", 3, "air", 12, false, nil, false, false, false)
  191. nssb_register_buildings ("megaformicaio", 7, "default:dirt_with_grass", 4, "default:dirt", 2, "air", 3, "air", 25, false, nil, false, false, false)
  192. nssb_register_buildings ("antqueenhill", 8, "default:dirt_with_grass", 4, "default:dirt", 2, "air", 3, "air", 21, false, nil, false, false, false)
  193. nssb_register_buildings ("rovine1", 4, "default:dirt_with_grass", 3, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  194. -- nssb_register_buildings ("rovine2", 1, "default:stone", 0, "air", 0, "air", 24, "default:jungletree", 5, true, -8, false, false)
  195. nssb_register_buildings ("rovine3", 4, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  196. nssb_register_buildings ("rovine4", 4, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  197. nssb_register_buildings ("rovine5", 4, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  198. nssb_register_buildings ("rovine6", 4, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  199. nssb_register_buildings ("rovine7", 4, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  200. nssb_register_buildings ("rovine8", 4, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  201. nssb_register_buildings ("rovine9", 4, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  202. nssb_register_buildings ("rovine10", 4, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  203. nssb_register_buildings ("bozzoli", 4, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  204. nssb_register_buildings ("picco", 12, "default:desert_sand", 1, "default:desert_stone", 1, "air", 3, "default:desert_sand", 10, false, nil, false, false, false)
  205. nssb_register_buildings ("piccoghiaccio", 12, "default:dirt_with_snow", 1, "default:dirt", 1, "air", 3, "default:dirt_with_snow", 10, false, nil, true, false, false)
  206. nssb_register_buildings ("icehall", 8, "default:dirt_with_snow", 1, "default:dirt", 1, "air", 3, "default:dirt_with_snow", 30, false, nil, true, false, false)
  207. nssb_register_buildings ("piccomoonheron", 8, "default:dirt_with_snow", 1, "default:dirt", 1, "air", 3, "default:dirt_with_snow", 3, false, nil, true, false, false)
  208. nssb_register_buildings ("doppiopiccoghiaccio", 11, "default:dirt_with_snow", 1, "default:dirt", 1, "air", 3, "default:dirt_with_snow", 7, false, nil, true, false, false)
  209. nssb_register_buildings ("doppiopiccosabbia", 11, "default:desert_sand", 1, "default:desert_stone", 1, "air", 3, "default:desert_sand", 7, false, nil, false, false, false)
  210. nssb_register_buildings ("piccoscrausics", 8, "default:desert_sand", 1, "default:desert_stone", 1, "air", 3, "default:desert_sand", 3, false, nil, false, false, false)
  211. nssb_register_buildings ("fossasand", 20, "default:desert_sand", 1, "default:desert_stone", 1, "air", 3, "default:desert_sand", 16, false, nil, false, false, false)
  212. nssb_register_buildings ("portal", 100, "default:dirt_with_grass", 2, "default:dirt", 2, "air", 24, "air", 11, false, nil, false, false, true)
  213. else -- mymapgenis 7
  214. nssb_register_buildings ("spiaggiagranchius", 5, "default:sand", 3, "default:sand", 2, "air", 3, "air", 0, false, nil, false, false, false)
  215. nssb_register_buildings ("acquagranchius", 6, "default:sand", 3, "default:sand", 12,"default:water_source", 3, "default:water_source", 0, false, nil, false, false, false)
  216. nssb_register_buildings ("ooteca", 12, "default:dirt_with_grass", 3, "default:dirt", 2, "air", 24, "default:tree", 8, false, nil, false, false, false)
  217. nssb_register_buildings ("minuscolaooteca", 11, "default:dirt_with_grass",3 , "default:dirt", 2, "air", 24, "default:tree", 2, false, nil, false, false, false)
  218. nssb_register_buildings ("piccolaooteca", 11, "default:dirt_with_grass", 2, "default:dirt", 2, "air", 24, "default:tree", 4, false, nil, false, false, false)
  219. nssb_register_buildings ("arcate", 24, "default:sand", 3, "default:sand", 13, "default:water_source", 3, "default:water_source",0, false, nil, false, false, false)
  220. nssb_register_buildings ("grandepiramide", 24, "default:dirt", 3, "default:dirt", 20, "default:water_source", 3, "default:water_source", 0, false, nil, false, false, false)
  221. nssb_register_buildings ("collina", 14, "default:dirt_with_grass", 3, "default:dirt", 2, "air", 3, "air", 12, false, nil, false, false, false)
  222. nssb_register_buildings ("megaformicaio", 20, "default:dirt_with_grass", 4, "default:dirt", 2, "air", 3, "air", 25, false, nil, false, false, false)
  223. nssb_register_buildings ("antqueenhill", 22, "default:dirt_with_grass", 4, "default:dirt", 2, "air", 3, "air", 21, false, nil, false, false, false)
  224. nssb_register_buildings ("rovine1", 6, "default:dirt_with_grass", 3, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  225. -- nssb_register_buildings ("rovine2", 1, "default:stone", 0, "air", 0, "air", 24, "default:jungletree", 5, true, -8, false, false)
  226. nssb_register_buildings ("rovine3", 6, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  227. nssb_register_buildings ("rovine4", 6, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  228. nssb_register_buildings ("rovine5", 6, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  229. nssb_register_buildings ("rovine6", 6, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  230. nssb_register_buildings ("rovine7", 6, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  231. nssb_register_buildings ("rovine8", 6, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  232. nssb_register_buildings ("rovine9", 6, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  233. nssb_register_buildings ("rovine10", 6, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  234. nssb_register_buildings ("bozzoli", 4, "default:dirt_with_grass", 1, "default:dirt", 2, "air", 8, "default:jungletree", 10, false, nil, false, false, false)
  235. nssb_register_buildings ("picco", 32, "default:desert_sand", 1, "default:desert_stone", 1, "air", 3, "default:desert_sand", 10, false, nil, false, false, false)
  236. nssb_register_buildings ("piccoghiaccio", 32, "default:dirt_with_snow", 1, "default:dirt", 1, "air", 3, "default:dirt_with_snow", 10, false, nil, true, false, false)
  237. nssb_register_buildings ("icehall", 40, "default:dirt_with_snow", 1, "default:dirt", 1, "air", 3, "default:dirt_with_snow", 30, false, nil, true, false, false)
  238. nssb_register_buildings ("piccomoonheron", 32, "default:dirt_with_snow", 1, "default:dirt", 1, "air", 3, "default:dirt_with_snow", 3, false, nil, true, false, false)
  239. nssb_register_buildings ("doppiopiccoghiaccio", 32, "default:dirt_with_snow", 1, "default:dirt", 1, "air", 3, "default:dirt_with_snow", 7, false, nil, true, false, false)
  240. nssb_register_buildings ("doppiopiccosabbia", 32, "default:desert_sand", 1, "default:desert_stone", 1, "air", 3, "default:desert_sand", 7, false, nil, false, false, false)
  241. nssb_register_buildings ("piccoscrausics", 32, "default:desert_sand", 1, "default:desert_stone", 1, "air", 3, "default:desert_sand", 3, false, nil, false, false, false)
  242. nssb_register_buildings ("fossasand", 50, "default:desert_sand", 1, "default:desert_stone", 1, "air", 3, "default:desert_sand", 16, false, nil, false, false, false)
  243. nssb_register_buildings ("portal", 200, "default:dirt_with_grass", 2, "default:dirt", 2, "air", 24, "air", 11, false, nil, false, false, true)
  244. end
  245. nssb_register_buildings ("blocohouse", 4, "default:stone", 0, "air", 0, "air", 3, "default:stone", 5, true, -10, false, false, false)
  246. nssb_register_buildings ("bigblocohouse", 4, "default:stone", 0, "air", 0, "air", 3, "default:stone", 5, true, -20, false, false, false)
  247. nssb_register_buildings ("blocobiggesthouse", 4, "default:stone", 0, "air", 0, "air", 3, "default:stone", 5, true, -30, false, false, false)
  248. -- nodes gen
  249. -- This dimension is "divided" in in 7 layer.
  250. -- 1st layer is indistructible, made of indistructible morentir
  251. local ite = is_50 and 1 or 9
  252. for i = 1, ite do
  253. minetest.register_ore({
  254. ore_type = oretype_morlan_layer,
  255. ore = "nssb:indistructible_morentir",
  256. wherein = {
  257. "default:water_source","default:water_flowing","default:gravel",
  258. "default:dirt", "default:sand", "default:lava_source", "default:lava_flowing",
  259. "default:mese_block", "default:stone", "air", "default:stone_with_coal",
  260. "default:stone_with_iron", "default:stone_with_mese",
  261. "default:stone_with_diamond", "default:stone_with_gold",
  262. "default:stone_with_copper", "nssb:ant_dirt", "default:stone",
  263. "default:cobble", "default:stonebrick", "default:mossycobble",
  264. "default:desert_stone", "default:desert_cobble", "default:desert_stonebrick",
  265. "default:sandstone", "default:sandstonebrick", "default:stone_with_tin",
  266. -- moreores (can be added to list, only removes if mod active)
  267. "moreores:mineral_tin", "moreores:mineral_silver", "moreores:mineral_mithril",
  268. "default:silver_sand"
  269. },
  270. clust_scarcity = 1,
  271. clust_num_ores = 1,
  272. clust_size = 1,
  273. y_min = level - 44,
  274. y_max = level - 37
  275. })
  276. end
  277. --[[
  278. if moreores then
  279. local ite = is_50 and 1 or 9
  280. for i = 1, ite do
  281. minetest.register_ore({
  282. ore_type = oretype_morlan_layer,
  283. ore = "nssb:indistructible_morentir",
  284. wherein = {
  285. "moreores:mineral_tin", "moreores:mineral_silver",
  286. "moreores:mineral_mithril"
  287. },
  288. clust_scarcity = 1,
  289. clust_num_ores = 1,
  290. clust_size = 1,
  291. y_min = level - 44,
  292. y_max = level - 37
  293. })
  294. end
  295. end
  296. ]]
  297. -- 2nd layer is "stalagmitic", have bats and morelentir
  298. local function replace2(old, new)
  299. local ite = is_50 and 1 or 9
  300. for i = 1, ite do
  301. minetest.register_ore({
  302. ore_type = oretype_morlan_layer,
  303. ore = new,
  304. wherein = old,
  305. clust_scarcity = 1,
  306. clust_num_ores = 1,
  307. clust_size = 1,
  308. y_min = level - 65,
  309. y_max = level - 45
  310. })
  311. end
  312. end
  313. -- optimized list
  314. replace2({"default:stone", "default:stone_with_coal", "default:stone_with_iron",
  315. "default:stone_with_mese", "default:stone_with_diamond", "default:silver_sand",
  316. "default:stone_with_gold", "default:stone_with_copper", "default:gravel",
  317. "default:dirt", "default:sand", "default:water_source", "default:water_flowing",
  318. "default:lava_source", "default:lava_flowing", "default:mese_block",
  319. "nssb:ant_dirt", "default:stone", "default:cobble", "default:stonebrick",
  320. "default:mossycobble", "default:desert_stone", "default:desert_cobble",
  321. "default:desert_stonebrick", "default:sandstone", "default:sandstonebrick"},
  322. "nssb:morelentir")
  323. replace2({"default:stone_with_tin", "moreores:mineral_tin", "moreores:mineral_silver",
  324. "moreores:mineral_mithril"}, "air")
  325. minetest.register_ore({
  326. ore_type = "blob",
  327. ore = "nssb:morvilya",
  328. wherein = "nssb:morentir",
  329. clust_scarcity = 15 * 15 * 15,
  330. clust_size = 6,
  331. y_min = level - 65,
  332. y_max = level - 45,
  333. noise_threshold = 0.0,
  334. noise_params = {
  335. offset = 0.5,
  336. scale = 0.2,
  337. spread = {x = 5, y = 5, z = 5},
  338. seed = 17676,
  339. octaves = 1,
  340. persist = 0.0
  341. },
  342. })
  343. for i = 1, 3 do
  344. minetest.register_ore({
  345. ore_type = "scatter",
  346. ore = "air",
  347. wherein = "nssb:morentir",
  348. clust_scarcity = 1,
  349. clust_num_ores = 1,
  350. clust_size = 1,
  351. y_min = level - 66,
  352. y_max = level - 58
  353. })
  354. -- if is_50 then break end
  355. end
  356. -- 3rd layer is made by air
  357. local ite = is_50 and 1 or 32
  358. for i = 1, ite do
  359. minetest.register_ore({
  360. ore_type = oretype_morlan_layer,
  361. ore = "air",
  362. wherein = {
  363. "nssb:ant_dirt", "default:stone", "default:cobble", "default:stonebrick",
  364. "default:mossycobble", "default:desert_stone", "default:desert_cobble",
  365. "default:desert_stonebrick", "default:sandstone", "default:sandstonebrick",
  366. "default:water_source", "default:water_flowing", "default:gravel",
  367. "default:dirt", "default:sand", "default:lava_source", "default:lava_flowing",
  368. "default:mese_block", "default:stone", "air", "default:stone_with_coal",
  369. "default:stone_with_iron", "default:stone_with_mese", "default:silver_sand",
  370. "default:stone_with_diamond", "default:stone_with_gold",
  371. "default:stone_with_copper", "default:stone_with_tin",
  372. -- moreores (can be added to list, only removes if mod active)
  373. "moreores:mineral_tin", "moreores:mineral_silver", "moreores:mineral_mithril"
  374. },
  375. clust_scarcity = 1,
  376. clust_num_ores = 1,
  377. clust_size = 1,
  378. y_min = level - 93,
  379. y_max = level - 66
  380. })
  381. end
  382. --[[
  383. if moreores then
  384. for i = 1, 9 do
  385. minetest.register_ore({
  386. ore_type = oretype_morlan_layer,
  387. ore = "air",
  388. wherein = {
  389. "moreores:mineral_tin", "moreores:mineral_silver",
  390. "moreores:mineral_mithril"
  391. },
  392. clust_scarcity = 1,
  393. clust_num_ores = 1,
  394. clust_size = 1,
  395. y_min = level - 93,
  396. y_max = level - 66
  397. })
  398. if is_50 then break end
  399. end
  400. end
  401. ]]
  402. minetest.register_ore({
  403. ore_type = "blob",
  404. ore = "nssb:morelentir",
  405. wherein = "air",
  406. clust_scarcity = 10 * 10 * 10,
  407. clust_size = 3,
  408. y_min = level - 68,
  409. y_max = level - 65,
  410. noise_threshold = 0.0,
  411. noise_params = {
  412. offset = 0.5,
  413. scale = 0.2,
  414. spread = {x = 5, y = 5, z = 5},
  415. seed = 17676,
  416. octaves = 1,
  417. persist = 0.0
  418. }
  419. })
  420. minetest.register_ore({
  421. ore_type = "blob",
  422. ore = "nssb:morelentir",
  423. wherein = "air",
  424. clust_scarcity = 16 * 16 * 16,
  425. clust_size = 6,
  426. y_min = level - 71,
  427. y_max = level - 65,
  428. noise_threshold = 0.0,
  429. noise_params = {
  430. offset = 0.5,
  431. scale = 0.2,
  432. spread = {x = 5, y = 5, z = 5},
  433. seed = 17676,
  434. octaves = 1,
  435. persist = 0.0
  436. }
  437. })
  438. minetest.register_ore({
  439. ore_type = "blob",
  440. ore = "nssb:morvilya",
  441. wherein = "nssb:morentir",
  442. clust_scarcity = 15 * 15 * 15,
  443. clust_size = 6,
  444. y_min = level - 92,
  445. y_max = level - 66,
  446. noise_threshold = 0.0,
  447. noise_params = {
  448. offset = 0.5,
  449. scale = 0.2,
  450. spread = {x = 5, y = 5, z = 5},
  451. seed = 17676,
  452. octaves = 1,
  453. persist = 0.0
  454. }
  455. })
  456. minetest.register_ore({
  457. ore_type = "blob",
  458. ore = "nssb:morentir",
  459. wherein = "air",
  460. clust_scarcity = 13 * 13 * 13,
  461. clust_size = 6,
  462. y_min = level - 95,
  463. y_max = level - 89,
  464. noise_threshold = 0.0,
  465. noise_params = {
  466. offset = 0.5,
  467. scale = 0.2,
  468. spread = {x = 5, y = 5, z = 5},
  469. seed = 17676,
  470. octaves = 1,
  471. persist = 0.0
  472. }
  473. })
  474. minetest.register_ore({
  475. ore_type = "blob",
  476. ore = "nssb:morentir",
  477. wherein = "air",
  478. clust_scarcity = 11 * 11 * 11,
  479. clust_size = 5,
  480. y_min = level - 95,
  481. y_max = level - 90,
  482. noise_threshold = 0.0,
  483. noise_params = {
  484. offset = 0.5,
  485. scale = 0.2,
  486. spread = {x = 5, y = 5, z = 5},
  487. seed = 17676,
  488. octaves = 1,
  489. persist = 0.0
  490. }
  491. })
  492. minetest.register_ore({
  493. ore_type = "blob",
  494. ore = "nssb:morentir",
  495. wherein = "air",
  496. clust_scarcity = 10 * 10 * 10,
  497. clust_size = 4,
  498. y_min = level - 95,
  499. y_max = level - 91,
  500. noise_threshold = 0.0,
  501. noise_params = {
  502. offset = 0.5,
  503. scale = 0.2,
  504. spread = {x = 5, y = 5, z = 5},
  505. seed = 17676,
  506. octaves = 1,
  507. persist = 0.0
  508. }
  509. })
  510. minetest.register_ore({
  511. ore_type = "blob",
  512. ore = "nssb:morentir",
  513. wherein = "air",
  514. clust_scarcity = 10 * 10 * 10,
  515. clust_size = 10,
  516. y_min = level - 95,
  517. y_max = level - 89,
  518. noise_threshold = 0.0,
  519. noise_params = {
  520. offset = 1,
  521. scale = 1,
  522. spread = {x = 1, y = 1000, z = 1},
  523. seed = 17676,
  524. octaves = 1,
  525. persist = 0.0
  526. }
  527. })
  528. -- 4th layer is a plain with mobs, fire, water...
  529. local function replace4(old, new)
  530. local ite = is_50 and 1 or 9
  531. for i = 1, ite do
  532. minetest.register_ore({
  533. ore_type = oretype_morlan_layer,
  534. ore = new,
  535. wherein = old,
  536. clust_scarcity = 1,
  537. clust_num_ores = 1,
  538. clust_size = 1,
  539. y_min = level - 107,
  540. y_max = level - 94
  541. })
  542. end
  543. end
  544. -- optimized list
  545. replace4({"default:stone_with_iron", "default:stone_with_mese", "default:stone_with_gold",
  546. "default:stone_with_diamond", "default:stone_with_copper"}, "air")
  547. replace4({"default:stone_with_coal", "default:lava_source", "default:water_source"},
  548. "nssb:mornen")
  549. replace4({"default:lava_flowing", "default:water_flowing"}, "nssb:moenen_flowing")
  550. replace4({"default:gravel", "default:dirt", "default:sand", "nssb:ant_dirt",
  551. "default:stone", "default:cobble", "default:stonebrick", "default:mossycobble",
  552. "default:desert_stone", "default:desert_cobble", "default:desert_stonebrick",
  553. "default:sandstone", "default:sandstonebrick", "default:silver_sand"},
  554. "nssb:morkemen")
  555. replace4({"default:stone", "default:stone_with_tin", "moreores:mineral_tin",
  556. "moreores:mineral_silver", "moreores:mineral_mithril"}, "nssb:morentir")
  557. replace4("default:mese_block", "nssb:life_energy_ore")
  558. minetest.register_ore({
  559. ore_type = "scatter",
  560. ore = "nssb:morlote",
  561. wherein = "air",
  562. clust_scarcity = 7 * 7 * 7,
  563. clust_num_ores = 1,
  564. clust_size = 1,
  565. y_min = level - 94,
  566. y_max = level - 93
  567. })
  568. minetest.register_ore({
  569. ore_type = "scatter",
  570. ore = "nssb:mornar",
  571. wherein = "air",
  572. clust_scarcity = 4 * 4 * 4,
  573. clust_num_ores = 1,
  574. clust_size = 1,
  575. y_min = level - 94,
  576. y_max = level - 93
  577. })
  578. minetest.register_ore({
  579. ore_type = "scatter",
  580. ore = "nssm:morwa_statue",
  581. wherein = "air",
  582. clust_scarcity = 18 * 18 * 18,
  583. clust_num_ores = 1,
  584. clust_size = 1,
  585. y_min = level - 94,
  586. y_max = level - 93
  587. })
  588. -- 5th layer is underground with caves
  589. local function replace5(old, new)
  590. local ite = is_50 and 1 or 9
  591. for i = 1, ite do
  592. minetest.register_ore({
  593. ore_type = oretype_morlan_layer,
  594. ore = new,
  595. wherein = old,
  596. clust_scarcity = 1,
  597. clust_num_ores = 1,
  598. clust_size = 1,
  599. y_min = level - 156,
  600. y_max = level - 108
  601. })
  602. end
  603. end
  604. minetest.register_ore({
  605. ore_type = "blob",
  606. ore = "nssb:fall_morentir",
  607. wherein = "air",
  608. clust_scarcity = 16 * 16 * 16,
  609. clust_size = 6,
  610. y_min = level - 204,
  611. y_max = level - 109,
  612. noise_threshold = 0.0,
  613. noise_params = {
  614. offset = 0.5,
  615. scale = 0.2,
  616. spread = {x = 5, y = 5, z = 5},
  617. seed = 17676,
  618. octaves = 1,
  619. persist = 0.0
  620. }
  621. })
  622. -- optimized list
  623. replace5({"default:stone", "default:stone_with_iron", "default:stone_with_mese",
  624. "default:stone_with_copper"}, "nssb:morentir")
  625. replace5({"default:stone_with_coal", "default:stone_with_diamond",
  626. "default:stone_with_gold", "default:mese_block", "default:stone_with_tin",
  627. "moreores:mineral_tin"}, "nssb:life_energy_ore")
  628. replace5({"default:lava_source", "default:lava_flowing", "moreores:mineral_silver"},
  629. "nssb:morentir")
  630. replace5("default:water_source", "nssb:mornen")
  631. replace5("default:water_flowing", "nssb:mornen_flowing")
  632. replace5("moreores:mineral_mithril", "nssb:moranga")
  633. replace5({"default:gravel", "default:dirt", "default:sand", "nssb:ant_dirt",
  634. "default:stone", "default:cobble", "default:stonebrick", "default:mossycobble",
  635. "default:desert_stone", "default:desert_cobble", "default:desert_stonebrick",
  636. "default:sandstone", "default:sandstonebrick", "default:silver_sand"},
  637. "nssb:morkemen")
  638. -- 6th layer is underground with other caves and the special metal
  639. local function replace6(old, new)
  640. local ite = is_50 and 1 or 9
  641. for i = 1, ite do
  642. minetest.register_ore({
  643. ore_type = oretype_morlan_layer,
  644. ore = new,
  645. wherein = old,
  646. clust_scarcity = 1,
  647. clust_num_ores = 1,
  648. clust_size = 1,
  649. y_min = level - 205,
  650. y_max = level - 157
  651. })
  652. end
  653. end
  654. -- optimized list
  655. replace6({"default:stone", "default:lava_source", "default:lava_flowing"},
  656. "nssb:morentir")
  657. replace6({"default:stone_with_coal", "default:stone_with_diamond",
  658. "default:stone_with_gold", "default:mese_block", "default:stone_with_tin",
  659. "moreores:mineral_tin"}, "nssb:life_energy_ore")
  660. replace6({"default:stone_with_iron", "default:stone_with_mese",
  661. "default:stone_with_copper", "moreores:mineral_silver",
  662. "moreores:mineral_mithril"}, "nssb:moranga")
  663. replace6({"default:gravel", "default:dirt", "default:sand", "nssb:ant_dirt",
  664. "default:stone", "default:cobble", "default:stonebrick", "default:mossycobble",
  665. "default:desert_stone", "default:desert_cobble", "default:desert_stonebrick",
  666. "default:sandstone", "default:sandstonebrick", "default:silver_sand"},
  667. "nssb:morkemen")
  668. replace6("default:water_source", "nssb:mornen")
  669. replace6("default:water_flowing", "nssb:mornen_flowing")
  670. minetest.register_ore({
  671. ore_type = "scatter",
  672. ore = "nssb:boum_morentir",
  673. wherein = "nssb:morentir",
  674. clust_scarcity = 13 * 13 * 13,
  675. clust_num_ores = 1,
  676. clust_size = 1,
  677. y_min = level - 205,
  678. y_max = level - 157
  679. })
  680. -- 7th layer is indistructible
  681. local ite = is_50 and 1 or 9
  682. for i = 1, ite do
  683. minetest.register_ore({
  684. ore_type = oretype_morlan_layer,
  685. ore = "nssb:indistructible_morentir",
  686. wherein = {
  687. "nssb:ant_dirt", "default:stone", "default:cobble", "default:stonebrick",
  688. "default:mossycobble", "default:desert_stone", "default:desert_cobble",
  689. "default:desert_stonebrick", "default:sandstone", "default:sandstonebrick",
  690. "default:water_source", "default:water_flowing", "default:gravel",
  691. "default:dirt", "default:sand", "default:lava_source", "default:lava_flowing",
  692. "default:mese_block", "default:stone", "air", "default:stone_with_coal",
  693. "default:stone_with_iron", "default:stone_with_mese", "default:silver_sand",
  694. "default:stone_with_diamond", "default:stone_with_gold",
  695. "default:stone_with_copper", "default:stone_with_tin",
  696. "moreores:mineral_tin", "moreores:mineral_silver", "moreores:mineral_mithril"
  697. },
  698. clust_scarcity = 1,
  699. clust_num_ores = 1,
  700. clust_size = 1,
  701. y_min = level - 213,
  702. y_max = level - 206
  703. })
  704. end
  705. --[[
  706. if moreores then
  707. local ite = is_50 and 1 or 9
  708. for i = 1, ite do
  709. minetest.register_ore({
  710. ore_type = oretype_morlan_layer,
  711. ore = "nssb:indistructible_morentir",
  712. wherein = {
  713. "moreores:mineral_tin", "moreores:mineral_silver",
  714. "moreores:mineral_mithril"
  715. },
  716. clust_scarcity = 1,
  717. clust_num_ores = 1,
  718. clust_size = 1,
  719. y_min = level - 213,
  720. y_max = level - 206
  721. })
  722. end
  723. end
  724. ]]
  725. local ite = is_50 and 1 or 12
  726. for i = 1, ite do
  727. minetest.register_ore({
  728. ore_type = oretype_morlan_layer,
  729. ore = "air",
  730. wherein = {
  731. "default:water_source", "default:water_flowing", "default:lava_source",
  732. "default:lava_flowing"
  733. },
  734. clust_scarcity = 1,
  735. clust_num_ores = 1,
  736. clust_size = 1,
  737. y_min = level - 207,
  738. y_max = level - 45
  739. })
  740. end
  741. -- Place the buildings in the morlendor
  742. posmorvalarblock = {x = 827, y = level - 94, z = -817}
  743. posplace = {x = 0, y = level - 93, z = 0}
  744. posmemory = {x = 0, y = level - 92, z = 0}
  745. if posplace then
  746. --[[if name11 == "ignore" then
  747. local pmin, pmax = minetest.get_voxel_manip():read_from_map(posplace, posplace)
  748. end
  749. ]]
  750. -- minetest.get_voxel_manip():read_from_map(posplace, posplace)
  751. if not minetest.get_node_or_nil(posplace) then
  752. minetest.emerge_area(vector.subtract(posplace, 80), vector.add(posplace, 80))
  753. end
  754. minetest.after(5, function(posplace)
  755. minetest.place_schematic(posplace, minetest.get_modpath("nssb")
  756. .. "/schems/memoportal.mts", 0, {}, true)
  757. end, posplace)
  758. end
  759. posarena = {x = 777, y = level - 96, z = -777}
  760. if posarena then
  761. -- minetest.get_voxel_manip():read_from_map(posplace, posplace)
  762. if not minetest.get_node_or_nil(posarena) then
  763. minetest.emerge_area(vector.subtract(posarena, 120), vector.add(posarena, 120))
  764. end
  765. -- teleport the player
  766. minetest.after(5, function(posarena)
  767. local mp = minetest.get_modpath("nssb")
  768. minetest.place_schematic(posarena, mp .. "/schems/arena51.mts", "0", {}, true)
  769. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-9},
  770. mp .. "/schems/arena52.mts", "0", {}, true)
  771. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-18},
  772. mp .. "/schems/arena53.mts", "0", {}, true)
  773. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-27},
  774. mp .. "/schems/arena54.mts", "0", {}, true)
  775. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-36},
  776. mp .. "/schems/arena55.mts", "0", {}, true)
  777. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-45},
  778. mp .. "/schems/arena56.mts", "0", {}, true)
  779. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-54},
  780. mp .. "/schems/arena57.mts", "0", {}, true)
  781. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-63},
  782. mp .. "/schems/arena58.mts", "0", {}, true)
  783. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-72},
  784. mp .. "/schems/arena59.mts", "0", {}, true)
  785. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-81},
  786. mp .. "/schems/arena510.mts", "0", {}, true)
  787. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-90},
  788. mp .. "/schems/arena511.mts", "0", {}, true)
  789. local objects = minetest.get_objects_inside_radius(posmorvalarblock, 90)
  790. local found = 0
  791. for _,obj in ipairs(objects) do
  792. if (obj:get_luaentity() and (obj:get_luaentity().name=="nssm:morvalar0"
  793. or obj:get_luaentity().name=="nssm:morvalar1"
  794. or obj:get_luaentity().name=="nssm:morvalar2"
  795. or obj:get_luaentity().name=="nssm:morvalar3"
  796. or obj:get_luaentity().name=="nssm:morvalar4"
  797. or obj:get_luaentity().name=="nssm:morvalar5"
  798. or obj:get_luaentity().name=="nssm:morvalar6"
  799. or obj:get_luaentity().name=="nssm:morvalar")) then
  800. found = 1
  801. end
  802. end
  803. if found == 0 then
  804. minetest.set_node(posmorvalarblock, {name="nssb:morvalar_block"})
  805. end
  806. end, posarena)
  807. end
  808. minetest.register_abm({
  809. nodenames = {"nssb:indistructible_morentir"},
  810. neighbors = {"nssb:mornar"},
  811. interval = 1,
  812. chance = 1,
  813. action = function(pos, node)
  814. -- minetest.chat_send_all("Ciao ciao pirloni")
  815. local mp = minetest.get_modpath("nssb")
  816. minetest.place_schematic(posarena, mp .. "/schems/arena51.mts", "0", {}, true)
  817. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-9},
  818. mp .. "/schems/arena52.mts", "0", {}, true)
  819. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-18},
  820. mp .. "/schems/arena53.mts", "0", {}, true)
  821. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-27},
  822. mp .. "/schems/arena54.mts", "0", {}, true)
  823. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-36},
  824. mp .. "/schems/arena55.mts", "0", {}, true)
  825. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-45},
  826. mp .. "/schems/arena56.mts", "0", {}, true)
  827. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-54},
  828. mp .. "/schems/arena57.mts", "0", {}, true)
  829. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-63},
  830. mp .. "/schems/arena58.mts", "0", {}, true)
  831. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-72},
  832. mp .. "/schems/arena59.mts", "0", {}, true)
  833. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-81},
  834. mp .. "/schems/arena510.mts", "0", {}, true)
  835. minetest.place_schematic({x = posarena.x, y = level - 96, z = posarena.z-90},
  836. mp .. "/schems/arena511.mts", "0", {}, true)
  837. end
  838. })
  839. --[[
  840. minetest.register_abm({
  841. nodenames = {"default:lava_source"},
  842. neighbors = {
  843. "nssb:morentir","nssb:morkemen", "nssb:morelentir", "nssb:mornen",
  844. "nssb:mornar","nssb:indistructible_morentir"
  845. },
  846. interval = 1,
  847. chance = 1,
  848. action = function(pos, node)
  849. minetest.set_node({x = pos.x, y = pos.y , z = pos.z}, {name = "air"})
  850. end
  851. })
  852. ]]
  853. minetest.register_abm({
  854. nodenames = {
  855. "default:lava_source", "default:lava_flowing", "default:water_source",
  856. "default:water_flowing"
  857. },
  858. neighbors = {"air"},
  859. interval = 1,
  860. chance = 1,
  861. action = function(pos, node)
  862. if pos.y < level then
  863. minetest.remove_node(pos)
  864. end
  865. end
  866. })
  867. -- If the generated chunks of map are in Morlendor remove the lava_source nodes
  868. --[[
  869. minetest.register_on_generated(function(minp, maxp, seed)
  870. if maxp.y > level then
  871. if minp.y < level then
  872. maxp.y = level
  873. else
  874. return
  875. end
  876. end
  877. minetest.chat_send_all("Ciao sono qui")
  878. local poslist = minetest.find_nodes_in_area(minp,maxp,"default:lava_source")
  879. for _,v in pairs(poslist) do
  880. minetest.chat_send_all("Posizione: "..pos_to_string)
  881. minetest.remove_node(v)
  882. end
  883. end)
  884. minetest.register_abm({
  885. nodenames = {"default:water_source"},
  886. neighbors = {
  887. "nssb:morentir","nssb:morkemen", "nssb:morelentir", "nssb:mornen",
  888. "nssb:mornar","nssb:indistructible_morentir"
  889. },
  890. interval = 1,
  891. chance = 1,
  892. action = function(pos, node)
  893. minetest.set_node({x = pos.x, y = pos.y , z = pos.z}, {name = "air"})
  894. end
  895. })
  896. ]]
  897. -- Abms
  898. minetest.register_abm({
  899. nodenames = {"default:torch"},
  900. neighbors = {"nssb:morentir","nssb:morkemen"},
  901. interval = 1,
  902. chance = 1,
  903. action = function(pos, node)
  904. minetest.set_node({x = pos.x, y = pos.y , z = pos.z}, {name = "nssb:mornar"})
  905. end
  906. })
  907. minetest.register_abm({
  908. nodenames = {"nssb:morlote"},
  909. neighbors = {"air"},
  910. interval = 60,
  911. chance = 100,
  912. action = function(pos, node)
  913. local pos1 = {x = pos.x, y = pos.y + 1, z = pos.z}
  914. local n = minetest.get_node(pos1).name
  915. if n ~= "air" then
  916. return
  917. end
  918. minetest.add_entity(pos1, "nssm:morgre")
  919. minetest.remove_node(pos)
  920. end
  921. })
  922. minetest.register_abm({
  923. nodenames = {"nssb:fall_morentir"},
  924. neighbors = {"nssb:fall_morentir"},
  925. interval = 1,
  926. chance = 1,
  927. action = function(pos, node)
  928. for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 7)) do
  929. if obj:is_player() then
  930. minetest.check_for_falling(pos)
  931. end
  932. end
  933. end
  934. })
  935. minetest.register_abm({
  936. nodenames = {"nssb:boum_morentir"},
  937. neighbors = {"nssb:morentir"},
  938. interval = 1,
  939. chance = 1,
  940. action = function(pos, node)
  941. for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 5)) do
  942. if obj:is_player() then
  943. tnt.boom(pos, {radius = 3, damage_radius = 0})
  944. end
  945. end
  946. end
  947. })
  948. minetest.register_abm({
  949. nodenames = {"nssb:mornen", "nssb:mornen_flowing"},
  950. neighbors = {"air"},
  951. interval = 1.0,
  952. chance = 5,
  953. action = function (pos, node)
  954. minetest.add_particlespawner({
  955. amount = 1,
  956. time = 2,
  957. minpos = {x = pos.x - 0.5, y = pos.y + 0.5, z = pos.z - 0.5},
  958. maxpos = {x = pos.x + 0.5, y = pos.y + 0.5, z = pos.z + 0.5},
  959. minvel = {x = 0, y = 0.1, z = 0},
  960. maxvel = {x = 0, y = 0.3, z = 0},
  961. minacc = {x = 0, y = 0, z = 0},
  962. maxacc = {x = 0, y = 0, z = 0},
  963. minexptime = 1,
  964. maxexptime = 1.2,
  965. minsize = 0.5,
  966. maxsize = 0.7,
  967. collisiondetection = false,
  968. vertical = true,
  969. texture = "morparticle.png"
  970. })
  971. end
  972. })
  973. minetest.register_abm({
  974. nodenames = {"nssb:portal"},
  975. neighbors = {"air"},
  976. interval = 1,
  977. chance = 1,
  978. action = function (pos, node)
  979. minetest.add_particlespawner({
  980. amount = 3,
  981. time = 1,
  982. minpos = {x = pos.x - 0.5, y = pos.y + 0.5, z = pos.z - 0.5},
  983. maxpos = {x = pos.x + 0.5, y = pos.y + 0.5, z = pos.z + 0.5},
  984. minvel = {x = 0, y = 0.1, z = 0},
  985. maxvel = {x = 0, y = 0.8, z = 0},
  986. minacc = {x = 0, y = 0, z = 0},
  987. maxacc = {x = 0, y = 0.4, z = 0},
  988. minexptime = 1,
  989. maxexptime = 3,
  990. minsize = 0.5,
  991. maxsize = 1.4,
  992. collisiondetection = false,
  993. vertical = true,
  994. texture = "morparticle.png"
  995. })
  996. end
  997. })
  998. minetest.register_abm({
  999. nodenames = {"nssb:portal"},
  1000. neighbors = {"air"},
  1001. interval = 7,
  1002. chance = 1,
  1003. action = function (pos, node)
  1004. for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
  1005. if obj:is_player() then
  1006. local pos1 = posmemory
  1007. local meta = minetest.get_meta(pos1)
  1008. -- the timer is saved inside a position because for me the tonumber
  1009. -- function doesn"t work
  1010. local timer_pos = minetest.string_to_pos(meta:get_string("player_timer"
  1011. .. obj:get_player_name()))
  1012. if not timer_pos or ((timer_pos) and ((os.time() - timer_pos.x) >= 30)) then
  1013. local posp = obj:get_pos()
  1014. -- minetest.chat_send_all("Posizione: "..minetest.pos_to_string(posp))
  1015. obj:set_pos({x = 5, y = pos1.y + 2, z = 5})
  1016. meta:set_string("player"..obj:get_player_name(), minetest.pos_to_string(posp))
  1017. timer_pos = {x = os.time(), y = 0, z = 0}
  1018. meta:set_string("player_timer" .. obj:get_player_name(),
  1019. minetest.pos_to_string(timer_pos))
  1020. end
  1021. end
  1022. end
  1023. end
  1024. })
  1025. minetest.register_abm({
  1026. nodenames = {"nssb:portalhome"},
  1027. neighbors = {"air"},
  1028. interval = 1,
  1029. chance = 1,
  1030. action = function (pos, node)
  1031. minetest.add_particlespawner({
  1032. amount = 3,
  1033. time = 1,
  1034. minpos = {x = pos.x - 0.5, y = pos.y + 0.5, z = pos.z - 0.5},
  1035. maxpos = {x = pos.x + 0.5, y = pos.y + 0.5, z = pos.z + 0.5},
  1036. minvel = {x = 0, y = 0.1, z = 0},
  1037. maxvel = {x = 0, y = 0.8, z = 0},
  1038. minacc = {x = 0, y = 0, z = 0},
  1039. maxacc = {x = 0, y = 0.4, z = 0},
  1040. minexptime = 1,
  1041. maxexptime = 3,
  1042. minsize = 0.5,
  1043. maxsize = 1.4,
  1044. collisiondetection = false,
  1045. vertical = true,
  1046. texture = "earth_particle.png"
  1047. })
  1048. end
  1049. })
  1050. minetest.register_abm({
  1051. nodenames = {"nssb:portalhome"},
  1052. neighbors = {"air"},
  1053. interval = 7,
  1054. chance = 2,
  1055. action = function (pos, node)
  1056. for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
  1057. if obj:is_player() then
  1058. local pos1 = posmemory
  1059. local meta = minetest.get_meta(pos1)
  1060. -- the timer is saved inside a position because for me the tonumber
  1061. -- function doesn"t work
  1062. local timer_pos = minetest.string_to_pos(meta:get_string("player_timer"
  1063. .. obj:get_player_name()))
  1064. if not timer_pos or ((timer_pos) and ((os.time() - timer_pos.x) >= 30)) then
  1065. local name = minetest.get_node(pos1).name
  1066. local target = minetest.string_to_pos(meta:get_string("player"
  1067. .. obj:get_player_name()))
  1068. if target then
  1069. obj:set_pos({x = target.x, y = target.y + 1, z = target.z})
  1070. timer_pos = {x = os.time(), y = 0, z = 0}
  1071. meta:set_string("player_timer"
  1072. .. obj:get_player_name(),
  1073. minetest.pos_to_string(timer_pos))
  1074. end
  1075. end
  1076. end
  1077. end
  1078. end
  1079. })