mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 11:33:44 +01:00
Add minetest.load_area (#8023)
This commit is contained in:
parent
aa5ec2ec02
commit
c6f784f43b
@ -3989,6 +3989,10 @@ Environment access
|
|||||||
* mode = `"quick"`: Clear objects immediately in loaded mapblocks,
|
* mode = `"quick"`: Clear objects immediately in loaded mapblocks,
|
||||||
clear objects in unloaded mapblocks only when the
|
clear objects in unloaded mapblocks only when the
|
||||||
mapblocks are next activated.
|
mapblocks are next activated.
|
||||||
|
* `minetest.load_area(pos1[, pos2])`
|
||||||
|
* Load the mapblocks containing the area from `pos1` to `pos2`.
|
||||||
|
`pos2` defaults to `pos1` if not specified.
|
||||||
|
* This function does not trigger map generation.
|
||||||
* `minetest.emerge_area(pos1, pos2, [callback], [param])`
|
* `minetest.emerge_area(pos1, pos2, [callback], [param])`
|
||||||
* Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
|
* Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
|
||||||
asynchronously fetched from memory, loaded from disk, or if inexistent,
|
asynchronously fetched from memory, loaded from disk, or if inexistent,
|
||||||
|
@ -1047,6 +1047,30 @@ int ModApiEnvMod::l_raycast(lua_State *L)
|
|||||||
return LuaRaycast::create_object(L);
|
return LuaRaycast::create_object(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load_area(p1, [p2])
|
||||||
|
// load mapblocks in area p1..p2, but do not generate map
|
||||||
|
int ModApiEnvMod::l_load_area(lua_State *L)
|
||||||
|
{
|
||||||
|
GET_ENV_PTR;
|
||||||
|
MAP_LOCK_REQUIRED;
|
||||||
|
|
||||||
|
Map *map = &(env->getMap());
|
||||||
|
v3s16 bp1 = getNodeBlockPos(check_v3s16(L, 1));
|
||||||
|
if (!lua_istable(L, 2)) {
|
||||||
|
map->emergeBlock(bp1);
|
||||||
|
} else {
|
||||||
|
v3s16 bp2 = getNodeBlockPos(check_v3s16(L, 2));
|
||||||
|
sortBoxVerticies(bp1, bp2);
|
||||||
|
for (s16 z = bp1.Z; z <= bp2.Z; z++)
|
||||||
|
for (s16 y = bp1.Y; y <= bp2.Y; y++)
|
||||||
|
for (s16 x = bp1.X; x <= bp2.X; x++) {
|
||||||
|
map->emergeBlock(v3s16(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// emerge_area(p1, p2, [callback, context])
|
// emerge_area(p1, p2, [callback, context])
|
||||||
// emerge mapblocks in area p1..p2, calls callback with context upon completion
|
// emerge mapblocks in area p1..p2, calls callback with context upon completion
|
||||||
int ModApiEnvMod::l_emerge_area(lua_State *L)
|
int ModApiEnvMod::l_emerge_area(lua_State *L)
|
||||||
@ -1287,6 +1311,7 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
|
|||||||
API_FCT(find_nodes_in_area);
|
API_FCT(find_nodes_in_area);
|
||||||
API_FCT(find_nodes_in_area_under_air);
|
API_FCT(find_nodes_in_area_under_air);
|
||||||
API_FCT(fix_light);
|
API_FCT(fix_light);
|
||||||
|
API_FCT(load_area);
|
||||||
API_FCT(emerge_area);
|
API_FCT(emerge_area);
|
||||||
API_FCT(delete_area);
|
API_FCT(delete_area);
|
||||||
API_FCT(get_perlin);
|
API_FCT(get_perlin);
|
||||||
|
@ -135,6 +135,9 @@ private:
|
|||||||
// fix_light(p1, p2) -> true/false
|
// fix_light(p1, p2) -> true/false
|
||||||
static int l_fix_light(lua_State *L);
|
static int l_fix_light(lua_State *L);
|
||||||
|
|
||||||
|
// load_area(p1)
|
||||||
|
static int l_load_area(lua_State *L);
|
||||||
|
|
||||||
// emerge_area(p1, p2)
|
// emerge_area(p1, p2)
|
||||||
static int l_emerge_area(lua_State *L);
|
static int l_emerge_area(lua_State *L);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user