mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Make line_of_sight return blocking node position
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user