Page 1 of 1

Limited mapgen?

PostPosted: Mon Jul 28, 2014 18:00
by Tedypig
Is there a way to limit the mapgen down to about ~5000(x,z) from 0,0,0? Depth could remain the same. I want a smaller map because I never use the whole thing anyway. Or even better, the ~5000 each way(x,z), with a gap of air about 1000 wide and then return to normal mapgen past that. So the main part would be a ~10000X~10000 square with a ~1000 wide square "ring" around it, then normal past that. If it's possible, or such a thing exists, please let me know. Or if you're iwlling to code it (if it's easy), that would be awesome as well. Thanks in advance!


- Tedypig

Re: Limited mapgen?

PostPosted: Mon Jul 28, 2014 18:15
by rubenwardy
This code limits to +/- 5000, but you can fall off the edge. I am not sure how to place 'ignore' or cancel chunk generating.
Also, it is not fully optimised.

Licence: wtfpl.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_generated(function(minp, maxp, seed)
   -- Set up voxel manip
   local t1 = os.clock()
   local vm, 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 data = vm:get_data()
   local c_ignore = minetest.get_content_id("air")
   local dist = 5000

   -- Loop through
   for z = minp.z, maxp.z do
      for x = minp.x, maxp.x do
         for y = minp.y, maxp.y do
            if x > dist or x < -dist or y > dist or y < -dist or z > dist or z < -dist then   
               local vi = a:index(x, y, z)
               data[vi] = c_ignore
            end
         end
      end
   end

   vm:set_data(data)
   vm:write_to_map(data)
end)


Note local dist = 5000

Re: Limited mapgen?

PostPosted: Mon Jul 28, 2014 18:23
by Tedypig
Wow, that was fast, thanks! I will try it out now.

Re: Limited mapgen?

PostPosted: Mon Jul 28, 2014 21:44
by ExeterDad
rubenwardy wrote:This code limits to +/- 5000, but you can fall off the edge. I am not sure how to place 'ignore' or cancel chunk generating.
Also, it is not fully optimised.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_generated(function(minp, maxp, seed)
   -- Set up voxel manip
   local t1 = os.clock()
   local vm, 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 data = vm:get_data()
   local c_ignore = minetest.get_content_id("air")
   local dist = 5000

   -- Loop through
   for z = minp.z, maxp.z do
      for x = minp.x, maxp.x do
         for y = minp.y, maxp.y do
            if x > dist or x < -dist or y > dist or y < -dist or z > dist or z < -dist then   
               local vi = a:index(x, y, z)
               data[vi] = c_ignore
            end
         end
      end
   end

   vm:set_data(data)
   vm:write_to_map(data)
end)


Note local dist = 5000

Adding this to my handy code snippet stash! Thanks!

Re: Limited mapgen?

PostPosted: Tue Jul 29, 2014 07:58
by Krock
It would be better to replace it with an invisible, solid node.. maybe write a complete mod with it?

Re: Limited mapgen?

PostPosted: Tue Jul 29, 2014 10:16
by Calinou
Krock wrote:It would be better to replace it with an invisible, solid node.. maybe write a complete mod with it?


Map Tools has the blocks you need for that, player clip, full clip, ignore-like…