Map block loading

Post Reply
User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Map block loading

by rubenwardy » Post

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)

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.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

sfan5
Moderator
Posts: 4095
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

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: 2135
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen
Location: A forest in the midwest
Contact:

by Evergreen » Post

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.
Back from the dead!

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

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.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

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

by PilzAdam » Post

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

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

What would you do instead?

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.

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.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
SegFault22
Member
Posts: 872
Joined: Mon May 21, 2012 03:17
Location: NaN

by SegFault22 » Post

Could we please call it "World" generation, rather than "Map" generation? Maps are flat, like Minecraft, but worlds can be anything else, right?
"All we need it the right major crisis and the nations will accept the new world order."

User avatar
webdesigner97
Member
Posts: 1328
Joined: Mon Jul 30, 2012 19:16
GitHub: webD97
IRC: webdesigner97
In-game: webdesigner97
Location: Cologne, Germany
Contact:

by webdesigner97 » Post

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: 450
Joined: Thu Nov 10, 2011 14:25

by xyz » Post

You can abuse VoxelManip to load blocks: https://github.com/xyzz/minetest-stress ... un.lua#L37

User avatar
webdesigner97
Member
Posts: 1328
Joined: Mon Jul 30, 2012 19:16
GitHub: webD97
IRC: webdesigner97
In-game: webdesigner97
Location: Cologne, Germany
Contact:

by webdesigner97 » Post

xyz wrote:You can abuse VoxelManip to load blocks: https://github.com/xyzz/minetest-stress ... un.lua#L37
oh :D

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

Ah, that's handy.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests