1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Make line_of_sight return blocking node position

This commit is contained in:
stujones11 2013-12-11 20:33:39 +00:00 committed by ShadowNinja
parent 33de69a173
commit d9ef072305
4 changed files with 16 additions and 6 deletions

View file

@ -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;
}