daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Jun 26th, 2013 34 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. minetest.register_on_generated(function(minp, maxp, seed)
  3.         local vm, data, emin, emax = minetest.get_mapgen_object("voxelmanip")
  4.         local a = VoxelArea:new{
  5.                 MinEdge={x=emin.x, y=emin.y, z=emin.z},
  6.                 MaxEdge={x=emax.x, y=emax.y, z=emax.z},
  7.         }
  8.  
  9.         local c_dirt = minetest.get_content_id("default:dirt")
  10.         local sidelen = maxp.x - minp.x + 1
  11.         local noise = minetest.get_perlin_map(
  12.                 {offset=0, scale=20, spread={x=250, y=250, z=250}, seed=5, octaves=5, persist=0.6},
  13.                 {x=sidelen, y=sidelen, z=sidelen}
  14.         )
  15.         local nvals = noise:get2dMap_flat({x=minp.x, y=minp.z})
  16.  
  17.         for z = minp.z, maxp.z do
  18.         for y = minp.y, maxp.y do
  19.         for x = minp.x, maxp.x do
  20.                 local ni = math.floor((z - minp.z) * sidelen + (x - minp.x) + 1)
  21.                 if y < nvals[ni] then
  22.                         local vi = a:index(x, y, z)
  23.                         data[vi] = c_dirt
  24.                 end
  25.         end
  26.         end
  27.         end
  28.  
  29.         vm:calc_lighting(
  30.                 {x=minp.x-16, y=minp.y, z=minp.z-16},
  31.                 {x=maxp.x+16, y=maxp.y, z=maxp.z+16}
  32.         )
  33.  
  34.         vm:write_chunk(data)
  35. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top