Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- minetest.register_on_generated(function(minp, maxp, seed)
- local vm, data, emin, emax = minetest.get_mapgen_object("voxelmanip")
- local a = VoxelArea:new{
- MinEdge={x=emin.x, y=emin.y, z=emin.z},
- MaxEdge={x=emax.x, y=emax.y, z=emax.z},
- }
- local c_dirt = minetest.get_content_id("default:dirt")
- local sidelen = maxp.x - minp.x + 1
- local noise = minetest.get_perlin_map(
- {offset=0, scale=20, spread={x=250, y=250, z=250}, seed=5, octaves=5, persist=0.6},
- {x=sidelen, y=sidelen, z=sidelen}
- )
- local nvals = noise:get2dMap_flat({x=minp.x, y=minp.z})
- for z = minp.z, maxp.z do
- for y = minp.y, maxp.y do
- for x = minp.x, maxp.x do
- local ni = math.floor((z - minp.z) * sidelen + (x - minp.x) + 1)
- if y < nvals[ni] then
- local vi = a:index(x, y, z)
- data[vi] = c_dirt
- end
- end
- end
- end
- vm:calc_lighting(
- {x=minp.x-16, y=minp.y, z=minp.z-16},
- {x=maxp.x+16, y=maxp.y, z=maxp.z+16}
- )
- vm:write_chunk(data)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement