Page 1 of 1

Map block loading

PostPosted: Fri Dec 13, 2013 09:06
by rubenwardy
This would be useful for mobs, map generation mods, etc.

This is similar to an entities keep loaded pull request, but this is much more controllable.

(if map generation mods, ie dr who, want to generate a tardis at 0,-3000,0, then it wont work because it is unloaded)

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.request_load_block(x,y,z)

minetest.register_on_unload_request(function(mapmanip,pos)
      -- returns false/null if it is ok to unload this area, according to this mod
end)

PostPosted: Fri Dec 13, 2013 12:51
by sfan5
minetest.register_on_load_request(function(mapmanip,pos)) does not seem useful at all

PostPosted: Fri Dec 13, 2013 14:13
by Evergreen
sfan5 wrote:minetest.register_on_load_request(function(mapmanip,pos)) does not seem useful at all
That function isn't useful, but I do think the request_load_block is.

PostPosted: Fri Dec 13, 2013 14:47
by rubenwardy
Yeah, there is not real reason why a mod would cancel a block load.

Also, there is no reason to unload a block.

PostPosted: Fri Dec 13, 2013 15:03
by PilzAdam
Currently the whole API is designed to hide mapblocks from Lua, and there is no need to break that concept.

PostPosted: Fri Dec 13, 2013 15:32
by rubenwardy
What would you do instead?

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
-- load lock
a = minetest.load(x,y,z,radius)

-- move
a:move(x,y,z)

-- later in program, maybe in another tick
a:close()


You could include that api shown above, and then create a handler in lua like the above.

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
on unload request:
     for each loadlock:
          if intersects block
                cancel unload

     allow unload

PostPosted: Sun Dec 15, 2013 03:47
by SegFault22
Could we please call it "World" generation, rather than "Map" generation? Maps are flat, like Minecraft, but worlds can be anything else, right?

PostPosted: Sun Dec 15, 2013 11:31
by webdesigner97
I like this. Keeps sewers and underground rails always loaded :)

PostPosted: Sun Dec 15, 2013 17:31
by xyz

PostPosted: Mon Dec 16, 2013 06:35
by webdesigner97
xyz wrote:You can abuse VoxelManip to load blocks: https://github.com/xyzz/minetest-stress/blob/master/tests/run.lua#L37

oh :D

PostPosted: Mon Dec 16, 2013 08:46
by rubenwardy
Ah, that's handy.