-minetest.register_on_generated(function(minp, maxp, seed)
- -- Generate regular ores
- generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+0, 1/8/8/8, 3, 8, -31000, 64)
- generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/12/12/12, 2, 3, -15, 2)
- generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/9/9/9, 3, 5, -63, -16)
- generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/7/7/7, 3, 5, -31000, -64)
-
- generate_ore("default:stone_with_mese", "default:stone", minp, maxp, seed+4, 1/16/16/16, 2, 3, -127, -64)
- generate_ore("default:stone_with_mese", "default:stone", minp, maxp, seed+5, 1/9/9/9, 3, 5, -31000, -128)
- generate_ore("default:mese", "default:stone", minp, maxp, seed+8, 1/16/16/16, 2, 3, -31000,-1024)
-
- generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+7, 1/24/24/24, 6,27, -31000, 0)
- generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+6, 1/24/24/24, 6,27, -31000, -64)
-
- if maxp.y >= 2 and minp.y <= 0 then
- -- Generate clay
- -- Assume X and Z lengths are equal
- local divlen = 4
- local divs = (maxp.x-minp.x)/divlen+1;
- for divx=0+1,divs-1-1 do
- for divz=0+1,divs-1-1 do
- local cx = minp.x + math.floor((divx+0.5)*divlen)
- local cz = minp.z + math.floor((divz+0.5)*divlen)
- if minetest.env:get_node({x=cx,y=1,z=cz}).name == "default:water_source" and
- minetest.env:get_node({x=cx,y=0,z=cz}).name == "default:sand" then
- local is_shallow = true
- local num_water_around = 0
- if minetest.env:get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then
- num_water_around = num_water_around + 1 end
- if minetest.env:get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then
- num_water_around = num_water_around + 1 end
- if minetest.env:get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then
- num_water_around = num_water_around + 1 end
- if minetest.env:get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then
- num_water_around = num_water_around + 1 end
- if num_water_around >= 2 then
- is_shallow = false
- end
- if is_shallow then
- for x1=-divlen,divlen do
- for z1=-divlen,divlen do
- if minetest.env:get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sand" then
- minetest.env:set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
- end
- end
- end
- end
- end
- end
- end
- -- Generate papyrus
- local perlin1 = minetest.env:get_perlin(354, 3, 0.7, 100)
- -- Assume X and Z lengths are equal
- local divlen = 8
- local divs = (maxp.x-minp.x)/divlen+1;
- for divx=0,divs-1 do
- for divz=0,divs-1 do
- local x0 = minp.x + math.floor((divx+0)*divlen)
- local z0 = minp.z + math.floor((divz+0)*divlen)
- local x1 = minp.x + math.floor((divx+1)*divlen)
- local z1 = minp.z + math.floor((divz+1)*divlen)
- -- Determine papyrus amount from perlin noise
- local papyrus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 45 - 20)
- -- Find random positions for papyrus based on this random
- local pr = PseudoRandom(seed+1)
- for i=0,papyrus_amount do
- local x = pr:next(x0, x1)
- local z = pr:next(z0, z1)
- if minetest.env:get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
- minetest.env:find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
- default.make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
- end
- end
- end
- end
- -- Generate cactuses
- local perlin1 = minetest.env:get_perlin(230, 3, 0.6, 100)
- -- Assume X and Z lengths are equal
- local divlen = 16
- local divs = (maxp.x-minp.x)/divlen+1;
- for divx=0,divs-1 do
- for divz=0,divs-1 do
- local x0 = minp.x + math.floor((divx+0)*divlen)
- local z0 = minp.z + math.floor((divz+0)*divlen)
- local x1 = minp.x + math.floor((divx+1)*divlen)
- local z1 = minp.z + math.floor((divz+1)*divlen)
- -- Determine cactus amount from perlin noise
- local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 6 - 3)
- -- Find random positions for cactus based on this random
- local pr = PseudoRandom(seed+1)
- for i=0,cactus_amount do
- local x = pr:next(x0, x1)
- local z = pr:next(z0, z1)
- -- Find ground level (0...15)
- local ground_y = nil
- for y=30,0,-1 do
- if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
- ground_y = y
- break
- end
- end
- -- If desert sand, make cactus
- if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
- default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4))
- end
- end
- end
- end
- -- Generate dry shrubs
- local perlin1 = minetest.env:get_perlin(329, 3, 0.6, 100)
- -- Assume X and Z lengths are equal
- local divlen = 16
- local divs = (maxp.x-minp.x)/divlen+1;
- for divx=0,divs-1 do
- for divz=0,divs-1 do
- local x0 = minp.x + math.floor((divx+0)*divlen)
- local z0 = minp.z + math.floor((divz+0)*divlen)
- local x1 = minp.x + math.floor((divx+1)*divlen)
- local z1 = minp.z + math.floor((divz+1)*divlen)
- -- Determine dry shrubs amount from perlin noise
- local shrub_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0)
- -- Find random positions for dry shrubs based on this random
- local pr = PseudoRandom(seed+1)
- for i=0,shrub_amount do
- local x = pr:next(x0, x1)
- local z = pr:next(z0, z1)
- -- Find ground level (0...15)
- local ground_y = nil
- for y=30,0,-1 do
- if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
- ground_y = y
- break
- end
- end
- -- If desert sand, make dry shrub
- if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
- local p = {x=x,y=ground_y+1,z=z}
- local nn = minetest.env:get_node(p).name
- if minetest.registered_nodes[nn] and
- minetest.registered_nodes[nn].buildable_to then
- minetest.env:set_node(p, {name="default:dry_shrub"})
- end
- end
- end
- end
- end
- end