Map block loading

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

Map block loading

by rubenwardy » Fri Dec 13, 2013 09:06

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)
Last edited by rubenwardy on Fri Dec 13, 2013 15:34, edited 1 time in total.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Fri Dec 13, 2013 12:51

minetest.register_on_load_request(function(mapmanip,pos)) does not seem useful at all
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Fri Dec 13, 2013 14:13

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.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

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

by rubenwardy » Fri Dec 13, 2013 14:47

Yeah, there is not real reason why a mod would cancel a block load.

Also, there is no reason to unload a block.
Last edited by rubenwardy on Fri Dec 13, 2013 15:34, edited 1 time in total.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Dec 13, 2013 15:03

Currently the whole API is designed to hide mapblocks from Lua, and there is no need to break that concept.
 

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

by rubenwardy » Fri Dec 13, 2013 15:32

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
Last edited by rubenwardy on Mon Dec 16, 2013 08:47, edited 1 time in total.
 

User avatar
SegFault22
Member
 
Posts: 870
Joined: Mon May 21, 2012 03:17

by SegFault22 » Sun Dec 15, 2013 03:47

Could we please call it "World" generation, rather than "Map" generation? Maps are flat, like Minecraft, but worlds can be anything else, right?
Resources are abundant; only money is scarce. People should not have to work hard and remain poor just to pay for the needs of survival.
Society can thrive without money - but only if productive members of society are rewarded for being productive.
 

User avatar
webdesigner97
Member
 
Posts: 1307
Joined: Mon Jul 30, 2012 19:16
GitHub: webD97
IRC: webdesigner97
In-game: webdesigner97

by webdesigner97 » Sun Dec 15, 2013 11:31

I like this. Keeps sewers and underground rails always loaded :)
Last edited by webdesigner97 on Sun Dec 15, 2013 11:31, edited 1 time in total.
 

User avatar
xyz
Member
 
Posts: 449
Joined: Thu Nov 10, 2011 14:25

by xyz » Sun Dec 15, 2013 17:31

 

User avatar
webdesigner97
Member
 
Posts: 1307
Joined: Mon Jul 30, 2012 19:16
GitHub: webD97
IRC: webdesigner97
In-game: webdesigner97

by webdesigner97 » Mon Dec 16, 2013 06:35

xyz wrote:You can abuse VoxelManip to load blocks: https://github.com/xyzz/minetest-stress/blob/master/tests/run.lua#L37

oh :D
 

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

by rubenwardy » Mon Dec 16, 2013 08:46

Ah, that's handy.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 5 guests

cron