aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2014-01-11 17:54:00 +0100
committerNovatux <nathanael.courant@laposte.net>2014-01-11 17:54:00 +0100
commit84b94eb19804484b689cec441e175628fd10335f (patch)
tree2f94c4bc1d9244160af36df8f6560f3c51c5056e /src/script
parente21b29f4227581162490cc70aaf4009118544f97 (diff)
downloadminetest-84b94eb19804484b689cec441e175628fd10335f.tar.gz
minetest-84b94eb19804484b689cec441e175628fd10335f.tar.bz2
minetest-84b94eb19804484b689cec441e175628fd10335f.zip
Add forceloading
Diffstat (limited to 'src/script')
-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);
};