aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api
diff options
context:
space:
mode:
authorsfence <sfence.software@gmail.com>2021-06-20 17:21:35 +0200
committerGitHub <noreply@github.com>2021-06-20 17:21:35 +0200
commitb10091be9b6b6c74a170b9444f856f83dd3fe952 (patch)
treec806e74b870be70fafe2323858bbd5bd4071f399 /src/script/cpp_api
parent1805775f3d54043c3b1e75e47b9b85e3b12bab00 (diff)
downloadminetest-b10091be9b6b6c74a170b9444f856f83dd3fe952.tar.gz
minetest-b10091be9b6b6c74a170b9444f856f83dd3fe952.tar.bz2
minetest-b10091be9b6b6c74a170b9444f856f83dd3fe952.zip
Add min_y and max_y checks for Active Block Modifiers (ABM) (#11333)
This check can be used by ABM to reduce CPU usage.
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r--src/script/cpp_api/s_env.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/script/cpp_api/s_env.cpp b/src/script/cpp_api/s_env.cpp
index 8da5debaa..c4a39a869 100644
--- a/src/script/cpp_api/s_env.cpp
+++ b/src/script/cpp_api/s_env.cpp
@@ -150,13 +150,19 @@ void ScriptApiEnv::initializeEnvironment(ServerEnvironment *env)
bool simple_catch_up = true;
getboolfield(L, current_abm, "catch_up", simple_catch_up);
+
+ s16 min_y = INT16_MIN;
+ getintfield(L, current_abm, "min_y", min_y);
+
+ s16 max_y = INT16_MAX;
+ getintfield(L, current_abm, "max_y", max_y);
lua_getfield(L, current_abm, "action");
luaL_checktype(L, current_abm + 1, LUA_TFUNCTION);
lua_pop(L, 1);
LuaABM *abm = new LuaABM(L, id, trigger_contents, required_neighbors,
- trigger_interval, trigger_chance, simple_catch_up);
+ trigger_interval, trigger_chance, simple_catch_up, min_y, max_y);
env->addActiveBlockModifier(abm);