aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_env.cpp23
-rw-r--r--src/script/lua_api/l_env.h8
2 files changed, 31 insertions, 0 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index d01889401..f75334750 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -798,6 +798,27 @@ int ModApiEnvMod::l_get_humidity(lua_State *L)
return 1;
}
+// minetest.forceload_block(blockpos)
+// blockpos = {x=num, y=num, z=num}
+int ModApiEnvMod::l_forceload_block(lua_State *L)
+{
+ GET_ENV_PTR;
+
+ v3s16 blockpos = read_v3s16(L, 1);
+ env->getForceloadedBlocks()->insert(blockpos);
+ return 0;
+}
+
+// minetest.forceload_free_block(blockpos)
+// blockpos = {x=num, y=num, z=num}
+int ModApiEnvMod::l_forceload_free_block(lua_State *L)
+{
+ GET_ENV_PTR;
+
+ v3s16 blockpos = read_v3s16(L, 1);
+ env->getForceloadedBlocks()->erase(blockpos);
+ return 0;
+}
void ModApiEnvMod::Initialize(lua_State *L, int top)
{
@@ -836,4 +857,6 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
API_FCT(transforming_liquid_add);
API_FCT(get_heat);
API_FCT(get_humidity);
+ API_FCT(forceload_block);
+ API_FCT(forceload_free_block);
}
diff --git a/src/script/lua_api/l_env.h b/src/script/lua_api/l_env.h
index 126349c6e..7e1cabe3f 100644
--- a/src/script/lua_api/l_env.h
+++ b/src/script/lua_api/l_env.h
@@ -151,6 +151,14 @@ private:
static int l_get_heat(lua_State *L);
static int l_get_humidity(lua_State *L);
+ // minetest.forceload_block(blockpos)
+ // forceloads a block
+ static int l_forceload_block(lua_State *L);
+
+ // minetest.forceload_free_block(blockpos)
+ // stops forceloading a position
+ static int l_forceload_free_block(lua_State *L);
+
public:
static void Initialize(lua_State *L, int top);
};