123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- local H_LAG = caverealms.config.h_lag --15 --max height for stalagmites
- local H_LAC = caverealms.config.h_lac --20 --...stalactites
- local H_CRY = caverealms.config.h_cry --9 --max height of glow crystals
- local H_CLAC = caverealms.config.h_clac --13 --max height of glow crystal stalactites
- function caverealms:above_solid(x,y,z,area,data)
- local c_air = minetest.get_content_id("air")
- local ai = area:index(x,y+1,z-3)
- if data[ai] == c_air then
- return false
- else
- return true
- end
- end
- function caverealms:below_solid(x,y,z,area,data)
- local c_air = minetest.get_content_id("air")
- local ai = area:index(x,y-1,z-3)
- if data[ai] == c_air then
- return false
- else
- return true
- end
- end
- --stalagmite spawner
- function caverealms:stalagmite(x,y,z, area, data)
- if not caverealms:below_solid(x,y,z,area,data) then
- return
- end
-
- --contest ids
- local c_stone = minetest.get_content_id("default:stone")
- local top = math.random(6,H_LAG) --grab a random height for the stalagmite
- for j = 0, top do --y
- for k = -3, 3 do
- for l = -3, 3 do
- if j == 0 then
- if k*k + l*l <= 9 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = c_stone
- end
- elseif j <= top/5 then
- if k*k + l*l <= 4 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = c_stone
- end
- elseif j <= top/5 * 3 then
- if k*k + l*l <= 1 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = c_stone
- end
- else
- local vi = area:index(x, y+j, z-3)
- data[vi] = c_stone
- end
- end
- end
- end
- end
- --stalactite spawner
- function caverealms:stalactite(x,y,z, area, data)
- if not caverealms:above_solid(x,y,z,area,data) then
- return
- end
- --contest ids
- local c_stone = minetest.get_content_id("default:stone")--("caverealms:limestone")
- local bot = math.random(-H_LAC, -6) --grab a random height for the stalagmite
- for j = bot, 0 do --y
- for k = -3, 3 do
- for l = -3, 3 do
- if j >= -1 then
- if k*k + l*l <= 9 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = c_stone
- end
- elseif j >= bot/5 then
- if k*k + l*l <= 4 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = c_stone
- end
- elseif j >= bot/5 * 3 then
- if k*k + l*l <= 1 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = c_stone
- end
- else
- local vi = area:index(x, y+j, z-3)
- data[vi] = c_stone
- end
- end
- end
- end
- end
- --glowing crystal stalagmite spawner
- function caverealms:crystal_stalagmite(x,y,z, area, data, biome)
- if not caverealms:below_solid(x,y,z,area,data) then
- return
- end
-
- --contest ids
- local c_stone = minetest.get_content_id("default:stone")
- local c_crystal = minetest.get_content_id("caverealms:glow_crystal")
- local c_crystore = minetest.get_content_id("caverealms:glow_ore")
- local c_emerald = minetest.get_content_id("caverealms:glow_emerald")
- local c_emore = minetest.get_content_id("caverealms:glow_emerald_ore")
- local c_mesecry = minetest.get_content_id("caverealms:glow_mese")
- local c_meseore = minetest.get_content_id("default:stone_with_mese")
- local c_ruby = minetest.get_content_id("caverealms:glow_ruby")
- local c_rubore = minetest.get_content_id("caverealms:glow_ruby_ore")
- local c_ameth = minetest.get_content_id("caverealms:glow_amethyst")
- local c_amethore = minetest.get_content_id("caverealms:glow_amethyst_ore")
- local c_ice = minetest.get_content_id("default:ice")
- local c_thinice = minetest.get_content_id("caverealms:thin_ice")
- --for randomness
- local mode = 1
- if math.random(15) == 1 then
- mode = 2
- end
- if biome == 3 then
- if math.random(25) == 1 then
- mode = 2
- else
- mode = 1
- end
- end
- if biome == 4 or biome == 5 then
- if math.random(3) == 1 then
- mode = 2
- end
- end
- local stalids = {
- { {c_crystore, c_crystal}, {c_emore, c_emerald} },
- { {c_emore, c_emerald}, {c_crystore, c_crystal} },
- { {c_emore, c_emerald}, {c_meseore, c_mesecry} },
- { {c_ice, c_thinice}, {c_crystore, c_crystal}},
- { {c_ice, c_thinice}, {c_crystore, c_crystal}},
- { {c_rubore, c_ruby}, {c_meseore, c_mesecry}},
- { {c_crystore, c_crystal}, {c_rubore, c_ruby} },
- { {c_rubore, c_ruby}, {c_emore, c_emerald}},
- { {c_amethore, c_ameth}, {c_meseore, c_mesecry} },
- }
- local nid_a
- local nid_b
- local nid_s = c_stone --stone base, will be rewritten to ice in certain biomes
- if biome > 3 and biome < 6 then
- if mode == 1 then
- nid_a = c_ice
- nid_b = c_thinice
- nid_s = c_ice
- else
- nid_a = c_crystore
- nid_b = c_crystal
- end
- elseif mode == 1 then
- nid_a = stalids[biome][1][1]
- nid_b = stalids[biome][1][2]
- else
- nid_a = stalids[biome][2][1]
- nid_b = stalids[biome][2][2]
- end
- local top = math.random(5,H_CRY) --grab a random height for the stalagmite
- for j = 0, top do --y
- for k = -3, 3 do
- for l = -3, 3 do
- if j == 0 then
- if k*k + l*l <= 9 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = nid_s
- end
- elseif j <= top/5 then
- if k*k + l*l <= 4 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = nid_a
- end
- elseif j <= top/5 * 3 then
- if k*k + l*l <= 1 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = nid_b
- end
- else
- local vi = area:index(x, y+j, z-3)
- data[vi] = nid_b
- end
- end
- end
- end
- end
- --crystal stalactite spawner
- function caverealms:crystal_stalactite(x,y,z, area, data, biome)
- if not caverealms:above_solid(x,y,z,area,data) then
- return
- end
- --contest ids
- local c_stone = minetest.get_content_id("default:stone")
- local c_crystore = minetest.get_content_id("caverealms:glow_ore")
- local c_crystal = minetest.get_content_id("caverealms:glow_crystal")
- local c_emerald = minetest.get_content_id("caverealms:glow_emerald")
- local c_emore = minetest.get_content_id("caverealms:glow_emerald_ore")
- local c_mesecry = minetest.get_content_id("caverealms:glow_mese")
- local c_meseore = minetest.get_content_id("default:stone_with_mese")
- local c_ruby = minetest.get_content_id("caverealms:glow_ruby")
- local c_rubore = minetest.get_content_id("caverealms:glow_ruby_ore")
- local c_ameth = minetest.get_content_id("caverealms:glow_amethyst")
- local c_amethore = minetest.get_content_id("caverealms:glow_amethyst_ore")
- local c_ice = minetest.get_content_id("default:ice")
- local c_thinice = minetest.get_content_id("caverealms:hanging_thin_ice")
- --for randomness
- local mode = 1
- if math.random(15) == 1 then
- mode = 2
- end
- if biome == 3 then
- if math.random(25) == 1 then
- mode = 2
- else
- mode = 1
- end
- end
- if biome == 4 or biome == 5 then
- if math.random(3) == 1 then
- mode = 2
- end
- end
- local stalids = {
- { {c_crystore, c_crystal}, {c_emore, c_emerald} },
- { {c_emore, c_emerald}, {c_crystore, c_crystal} },
- { {c_emore, c_emerald}, {c_meseore, c_mesecry} },
- { {c_ice, c_thinice}, {c_crystore, c_crystal}},
- { {c_ice, c_thinice}, {c_crystore, c_crystal}},
- { {c_rubore, c_ruby}, {c_meseore, c_mesecry}},
- { {c_crystore, c_crystal}, {c_rubore, c_ruby} },
- { {c_rubore, c_ruby}, {c_emore, c_emerald}},
- { {c_amethore, c_ameth}, {c_meseore, c_mesecry} },
- }
- local nid_a
- local nid_b
- local nid_s = c_stone --stone base, will be rewritten to ice in certain biomes
- if biome > 3 and biome < 6 then
- if mode == 1 then
- nid_a = c_ice
- nid_b = c_thinice
- nid_s = c_ice
- else
- nid_a = c_crystore
- nid_b = c_crystal
- end
- elseif mode == 1 then
- nid_a = stalids[biome][1][1]
- nid_b = stalids[biome][1][2]
- else
- nid_a = stalids[biome][2][1]
- nid_b = stalids[biome][2][2]
- end
- local bot = math.random(-H_CLAC, -6) --grab a random height for the stalagmite
- for j = bot, 0 do --y
- for k = -3, 3 do
- for l = -3, 3 do
- if j >= -1 then
- if k*k + l*l <= 9 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = nid_s
- end
- elseif j >= bot/5 then
- if k*k + l*l <= 4 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = nid_a
- end
- elseif j >= bot/5 * 3 then
- if k*k + l*l <= 1 then
- local vi = area:index(x+k, y+j, z+l-3)
- data[vi] = nid_b
- end
- else
- local vi = area:index(x, y+j, z-3)
- data[vi] = nid_b
- end
- end
- end
- end
- end
- --glowing crystal stalagmite spawner
- function caverealms:salt_stalagmite(x,y,z, area, data, biome)
- if not caverealms:below_solid(x,y,z,area,data) then
- return
- end
-
- --contest ids
- local c_stone = minetest.get_content_id("default:stone")
- local c_salt = minetest.get_content_id("caverealms:salt_crystal")
-
- local scale = math.random(2, 4)
- if scale == 2 then
- for j = -3, 3 do
- for k = -3, 3 do
- local vi = area:index(x+j, y, z+k)
- data[vi] = c_stone
- if math.abs(j) ~= 3 and math.abs(k) ~= 3 then
- local vi = area:index(x+j, y+1, z+k)
- data[vi] = c_stone
- end
- end
- end
- else
- for j = -4, 4 do
- for k = -4, 4 do
- local vi = area:index(x+j, y, z+k)
- data[vi] = c_stone
- if math.abs(j) ~= 4 and math.abs(k) ~= 4 then
- local vi = area:index(x+j, y+1, z+k)
- data[vi] = c_stone
- end
- end
- end
- end
- for j = 2, scale + 2 do --y
- for k = -2, scale - 2 do
- for l = -2, scale - 2 do
- local vi = area:index(x+k, y+j, z+l)
- data[vi] = c_salt -- make cube
- end
- end
- end
- end
- --function to create giant 'shrooms
- function caverealms:giant_shroom(x, y, z, area, data)
- if not caverealms:below_solid(x,y,z,area,data) then
- return
- end
- local c_cap
- local c_stem
- --as usual, grab the content ID's
- if minetest.get_modpath("ethereal") then
- c_stem = minetest.get_content_id("ethereal:mushroom_trunk")
- c_cap = minetest.get_content_id("ethereal:mushroom")
- else
- c_stem = minetest.get_content_id("caverealms:mushroom_stem")
- c_cap = minetest.get_content_id("caverealms:mushroom_cap")
- end
-
- local c_gills = minetest.get_content_id("caverealms:mushroom_gills")
- z = z - 5
- --cap
- for k = -5, 5 do
- for l = -5, 5 do
- if k*k + l*l <= 25 then
- local vi = area:index(x+k, y+5, z+l)
- data[vi] = c_cap
- end
- if k*k + l*l <= 16 then
- local vi = area:index(x+k, y+6, z+l)
- data[vi] = c_cap
- vi = area:index(x+k, y+5, z+l)
- data[vi] = c_gills
- end
- if k*k + l*l <= 9 then
- local vi = area:index(x+k, y+7, z+l)
- data[vi] = c_cap
- end
- if k*k + l*l <= 4 then
- local vi = area:index(x+k, y+8, z+l)
- data[vi] = c_cap
- end
- end
- end
- --stem
- for j = 0, 5 do
- for k = -1,1 do
- local vi = area:index(x+k, y+j, z)
- data[vi] = c_stem
- if k == 0 then
- local ai = area:index(x, y+j, z+1)
- data[ai] = c_stem
- ai = area:index(x, y+j, z-1)
- data[ai] = c_stem
- end
- end
- end
- end
|