Limited mapgen?

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

Limited mapgen?

by Tedypig » Mon Jul 28, 2014 18:00

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
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Limited mapgen?

by rubenwardy » Mon Jul 28, 2014 18:15

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
Last edited by rubenwardy on Mon Jul 28, 2014 22:31, edited 3 times in total.
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

Re: Limited mapgen?

by Tedypig » Mon Jul 28, 2014 18:23

Wow, that was fast, thanks! I will try it out now.
 

User avatar
ExeterDad
Member
 
Posts: 1121
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad

Re: Limited mapgen?

by ExeterDad » Mon Jul 28, 2014 21:44

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!
٩(̾●̮̮̃̾•̃̾)۶

Kibbie and I have a beautiful public server now! HOMETOWN
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Limited mapgen?

by Krock » Tue Jul 29, 2014 07:58

It would be better to replace it with an invisible, solid node.. maybe write a complete mod with it?
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

Re: Limited mapgen?

by Calinou » Tue Jul 29, 2014 10:16

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…
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 8 guests

cron