-- minetest/default/mapgen.lua -- -- Aliases for map generator outputs -- minetest.register_alias("mapgen_air", "air") minetest.register_alias("mapgen_stone", "default:stone") minetest.register_alias("mapgen_apple", "default:apple") minetest.register_alias("mapgen_water_source", "default:water_source") minetest.register_alias("mapgen_dirt", "default:dirt") minetest.register_alias("mapgen_sand", "default:sand") minetest.register_alias("mapgen_gravel", "default:gravel") minetest.register_alias("mapgen_clay", "grounds:clay") minetest.register_alias("mapgen_lava_source", "default:lava_source") minetest.register_alias("mapgen_cobble", "default:cobble") minetest.register_alias("mapgen_mossycobble", "default:mossycobble") minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass") minetest.register_alias("mapgen_desert_sand", "default:desert_sand") minetest.register_alias("mapgen_desert_stone", "default:desert_stone") minetest.register_alias("mapgen_tree", "air") minetest.register_alias("mapgen_leaves", "air") function default.make_papyrus(pos, size) for y=0,size-1 do local p = {x=pos.x, y=pos.y+y, z=pos.z} minetest.set_node(p, {name="default:papyrus"}) end end function default.make_cactus(pos, size) for y=0,size-1 do local p = {x=pos.x, y=pos.y+y, z=pos.z} minetest.set_node(p, {name="default:cactus"}) end end minetest.register_on_generated(function(minp, maxp, seed) if maxp.y >= 2 and minp.y <= 0 then -- Generate papyrus local perlin1 = minetest.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.get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and minetest.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.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.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.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 cobbles local perlin1 = minetest.get_perlin(200, 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) local cobbles_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0) local pr = PseudoRandom(seed+1) for i=0,cobbles_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.get_node({x=x,y=y,z=z}).name ~= "air" then ground_y = y break end end if ground_y and minetest.get_node({x=x,y=ground_y,z=z}).name == "default:dirt_with_grass" then minetest.add_node({x=x,y=ground_y+1,z=z}, {name = "default:cobble_node"}) end end end end -- Generate dry shrubs local perlin1 = minetest.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 cactus amount from perlin noise local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0) -- 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.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.get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then minetest.set_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"}) end end end end end end)