Jeija wrote:+1=3! That's what we need! (I'm just interested if performance is ok then)
minetest.load_node(pos)
^ Returns true if the volume in which the node is could be loaded, or
already was loaded, in which case it then is available regularly by
minetest.env:get/set_node()
minetest.load_node_async(pos, func(pos, success, param), param)
^ If pos is in a loaded area, will return true
^ If pos is not loaded, will return false and queue the load. When the load
completes, func(pos, true, param) will be called in case the load was
succesful, and func(pos, false, param) will be called in case the node
could not be loaded (which, in practice, means that the area has not been
generated.)
celeron55 wrote:There are two ways to load a MapBlock - one is to add it to the load queue and wait until the "EmergeThread" gets to loading it in the background, while continuing doing other things, like moving objects and doing block placement and everything.
The other one is to just block everything until the block has been read from disk, which can take, well, a good fraction of a second, if not longer in the worst case, and can be annoying to the players. There is no way the server could continue running while a Lua callback has not returned.
I am guessing the blocking way would need to be used, because otherwise coding the delayed action is a bitch.
Also, sometimes a MapBlock hasn't been generated at all. In that case I think I won't let the Lua script to generate it; the generator generates stuff in huge bunches and the latency is just completely horrible. Maybe it would be possible to generate an empty area marked as not generated; the map generator could mess up anything added in there though.
Maybe something like: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.load_node(pos)
^ Returns true if the volume in which the node is could be loaded, or
already was loaded, in which case it then is available regularly by
minetest.env:get/set_node()
This is trickier to implement, but could be made in the future if really needed: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.load_node_async(pos, func(pos, success, param), param)
^ If pos is in a loaded area, will return true
^ If pos is not loaded, will return false and queue the load. When the load
completes, func(pos, true, param) will be called in case the load was
succesful, and func(pos, false, param) will be called in case the node
could not be loaded (which, in practice, means that the area has not been
generated.)
In both of these cases, the area will be automatically unloaded when it hasn't been used for a while.
celeron55 wrote:There are two ways to load a MapBlock - one is to add it to the load queue and wait until the "EmergeThread" gets to loading it in the background, while continuing doing other things, like moving objects and doing block placement and everything.
The other one is to just block everything until the block has been read from disk, which can take, well, a good fraction of a second, if not longer in the worst case, and can be annoying to the players. There is no way the server could continue running while a Lua callback has not returned.
I am guessing the blocking way would need to be used, because otherwise coding the delayed action is a bitch.
Also, sometimes a MapBlock hasn't been generated at all. In that case I think I won't let the Lua script to generate it; the generator generates stuff in huge bunches and the latency is just completely horrible. Maybe it would be possible to generate an empty area marked as not generated; the map generator could mess up anything added in there though.
Maybe something like: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.load_node(pos)
^ Returns true if the volume in which the node is could be loaded, or
already was loaded, in which case it then is available regularly by
minetest.env:get/set_node()
This is trickier to implement, but could be made in the future if really needed: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.load_node_async(pos, func(pos, success, param), param)
^ If pos is in a loaded area, will return true
^ If pos is not loaded, will return false and queue the load. When the load
completes, func(pos, true, param) will be called in case the load was
succesful, and func(pos, false, param) will be called in case the node
could not be loaded (which, in practice, means that the area has not been
generated.)
In both of these cases, the area will be automatically unloaded when it hasn't been used for a while.
Users browsing this forum: No registered users and 3 guests