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:
parent
33de69a173
commit
d9ef072305
4 changed files with 16 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue