From d9ef072305b92b020ebe473765118cca0e23608a Mon Sep 17 00:00:00 2001 From: stujones11 Date: Wed, 11 Dec 2013 20:33:39 +0000 Subject: Make line_of_sight return blocking node position --- src/script/lua_api/l_env.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/script/lua_api/l_env.cpp') 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; } -- cgit v1.2.3