From e09c7fceaa93ad3d7d85f657df0663f6efc70281 Mon Sep 17 00:00:00 2001 From: you Date: Sun, 27 Aug 2017 18:38:50 +0200 Subject: [PATCH] core.get_objects_inside_radius: Omit removed objects (#6318) Fixes #6294 --- doc/lua_api.txt | 2 +- src/script/lua_api/l_env.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 152da5985..d8e58f2a8 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -2555,7 +2555,7 @@ and `minetest.auth_reload` call the authetification handler. * `minetest.add_item(pos, item)`: Spawn item * Returns `ObjectRef`, or `nil` if failed * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player -* `minetest.get_objects_inside_radius(pos, radius)` +* `minetest.get_objects_inside_radius(pos, radius)`: returns a list of ObjectRefs * `radius`: using an euclidean metric * `minetest.set_timeofday(val)` * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 07d33a4eb..be92365ac 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -642,9 +642,11 @@ int ModApiEnvMod::l_get_objects_inside_radius(lua_State *L) std::vector::const_iterator iter = ids.begin(); for(u32 i = 0; iter != ids.end(); ++iter) { ServerActiveObject *obj = env->getActiveObject(*iter); - // Insert object reference into table - script->objectrefGetOrCreate(L, obj); - lua_rawseti(L, -2, ++i); + if (!obj->m_removed) { + // Insert object reference into table + script->objectrefGetOrCreate(L, obj); + lua_rawseti(L, -2, ++i); + } } return 1; } -- 2.25.1