aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorstujones11 <stujones11@server.fake>2013-12-11 20:33:39 +0000
committerShadowNinja <shadowninja@minetest.net>2013-12-12 16:11:00 -0500
commitd9ef072305b92b020ebe473765118cca0e23608a (patch)
treed3232745cfe75bed24cbaeff33c1a11409bbd139 /src/script/lua_api
parent33de69a173a3646d8f5b9bf91b3e48d76cd40ae6 (diff)
downloadminetest-d9ef072305b92b020ebe473765118cca0e23608a.tar.gz
minetest-d9ef072305b92b020ebe473765118cca0e23608a.tar.bz2
minetest-d9ef072305b92b020ebe473765118cca0e23608a.zip
Make line_of_sight return blocking node position
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_env.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index 4a8150396..d01889401 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -648,7 +648,7 @@ int ModApiEnvMod::l_clear_objects(lua_State *L)
return 0;
}
-// minetest.line_of_sight(pos1, pos2, stepsize) -> true/false
+// minetest.line_of_sight(pos1, pos2, stepsize) -> true/false, pos
int ModApiEnvMod::l_line_of_sight(lua_State *L) {
float stepsize = 1.0;
@@ -663,7 +663,13 @@ int ModApiEnvMod::l_line_of_sight(lua_State *L) {
stepsize = lua_tonumber(L, 3);
}
- lua_pushboolean(L, env->line_of_sight(pos1,pos2,stepsize));
+ v3s16 p;
+ bool success = env->line_of_sight(pos1, pos2, stepsize, &p);
+ lua_pushboolean(L, success);
+ if (!success) {
+ push_v3s16(L, p);
+ return 2;
+ }
return 1;
}