aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2019-11-09 00:22:42 +0100
committersfan5 <sfan5@live.de>2019-11-11 14:06:48 +0100
commitb57dc70769873e00ca7a7642862eb209a5528ce2 (patch)
treef0f79e77d7996469350033dc2fe1ef7319133c39 /src/script/lua_api
parentb0260b5ec8e05e54928f9487bb39b4ff946951f9 (diff)
downloadminetest-b57dc70769873e00ca7a7642862eb209a5528ce2.tar.gz
minetest-b57dc70769873e00ca7a7642862eb209a5528ce2.tar.bz2
minetest-b57dc70769873e00ca7a7642862eb209a5528ce2.zip
[CSM] Expose more env functions
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_env.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index 203ffcfdc..762612af4 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -140,17 +140,20 @@ void LuaLBM::trigger(ServerEnvironment *env, v3s16 p, MapNode n)
int LuaRaycast::l_next(lua_State *L)
{
MAP_LOCK_REQUIRED;
-
- ScriptApiItem *script = getScriptApi<ScriptApiItem>(L);
GET_ENV_PTR;
+ bool csm = false;
+#ifndef SERVER
+ csm = getClient(L) != nullptr;
+#endif
+
LuaRaycast *o = checkobject(L, 1);
PointedThing pointed;
env->continueRaycast(&o->state, &pointed);
if (pointed.type == POINTEDTHING_NOTHING)
lua_pushnil(L);
else
- script->pushPointedThing(pointed, true);
+ push_pointed_thing(L, pointed, csm, true);
return 1;
}
@@ -793,11 +796,20 @@ int ModApiEnvMod::l_find_nodes_in_area(lua_State *L)
{
GET_ENV_PTR;
- const NodeDefManager *ndef = getServer(L)->ndef();
v3s16 minp = read_v3s16(L, 1);
v3s16 maxp = read_v3s16(L, 2);
sortBoxVerticies(minp, maxp);
+#ifndef SERVER
+ const NodeDefManager *ndef = getClient(L) ? getClient(L)->ndef() : getServer(L)->ndef();
+ if (getClient(L)) {
+ minp = getClient(L)->CSMClampPos(minp);
+ maxp = getClient(L)->CSMClampPos(maxp);
+ }
+#else
+ const NodeDefManager *ndef = getServer(L)->ndef();
+#endif
+
v3s16 cube = maxp - minp + 1;
// Volume limit equal to 8 default mapchunks, (80 * 2) ^ 3 = 4,096,000
if ((u64)cube.X * (u64)cube.Y * (u64)cube.Z > 4096000) {
@@ -861,11 +873,20 @@ int ModApiEnvMod::l_find_nodes_in_area_under_air(lua_State *L)
GET_ENV_PTR;
- const NodeDefManager *ndef = getServer(L)->ndef();
v3s16 minp = read_v3s16(L, 1);
v3s16 maxp = read_v3s16(L, 2);
sortBoxVerticies(minp, maxp);
+#ifndef SERVER
+ const NodeDefManager *ndef = getClient(L) ? getClient(L)->ndef() : getServer(L)->ndef();
+ if (getClient(L)) {
+ minp = getClient(L)->CSMClampPos(minp);
+ maxp = getClient(L)->CSMClampPos(maxp);
+ }
+#else
+ const NodeDefManager *ndef = getServer(L)->ndef();
+#endif
+
v3s16 cube = maxp - minp + 1;
// Volume limit equal to 8 default mapchunks, (80 * 2) ^ 3 = 4,096,000
if ((u64)cube.X * (u64)cube.Y * (u64)cube.Z > 4096000) {
@@ -1326,8 +1347,14 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
void ModApiEnvMod::InitializeClient(lua_State *L, int top)
{
+ API_FCT(get_node_light);
API_FCT(get_timeofday);
API_FCT(get_node_max_level);
API_FCT(get_node_level);
+ API_FCT(find_nodes_with_meta);
API_FCT(find_node_near);
+ API_FCT(find_nodes_in_area);
+ API_FCT(find_nodes_in_area_under_air);
+ API_FCT(line_of_sight);
+ API_FCT(raycast);
}