aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_env.cpp
diff options
context:
space:
mode:
authorHybridDog <ovvv@web.de>2018-12-31 01:32:54 +0100
committerParamat <paramat@users.noreply.github.com>2018-12-31 00:32:54 +0000
commitc6f784f43bca3328c6810c26c8bda2ea507c70e8 (patch)
treebfd61739a0a71b03a9f8f19770df25b579144b17 /src/script/lua_api/l_env.cpp
parentaa5ec2ec02f331542dfe40e781c7c93ee4c0c131 (diff)
downloadminetest-c6f784f43bca3328c6810c26c8bda2ea507c70e8.tar.gz
minetest-c6f784f43bca3328c6810c26c8bda2ea507c70e8.tar.bz2
minetest-c6f784f43bca3328c6810c26c8bda2ea507c70e8.zip
Add minetest.load_area (#8023)
Diffstat (limited to 'src/script/lua_api/l_env.cpp')
-rw-r--r--src/script/lua_api/l_env.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index ba2be0cb5..711bd3fdd 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -1047,6 +1047,30 @@ int ModApiEnvMod::l_raycast(lua_State *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 mapblocks in area p1..p2, calls callback with context upon completion
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_under_air);
API_FCT(fix_light);
+ API_FCT(load_area);
API_FCT(emerge_area);
API_FCT(delete_area);
API_FCT(get_perlin);