Apply suggestions from code review

Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
Lars Müller 2024-06-22 14:21:14 +02:00 committed by GitHub
parent 89079a6619
commit e00f1d0763
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

@ -6126,9 +6126,11 @@ Environment access
* `minetest.get_objects_inside_radius(center, radius)`
* returns a list of ObjectRefs
* `radius`: using a Euclidean metric
* **Warning**: If you modify objects (f.e. punch them),
this may cause later objects in the list (f.e. children) to become invalid.
Use `minetest.objects_inside_radius` instead to iterate only valid objects
* **Warning**: Any kind of interaction with the environment or other APIs
can cause later objects in the list to become invalid while you're iterating it.
(e.g. punching an entity removes its children)
It is recommend to use `minetest.objects_inside_radius` instead, which
transparently takes care of this possibility.
* `minetest.objects_inside_radius(center, radius)`
* returns an iterator of valid objects
* example: `for obj in minetest.objects_inside_radius(center, radius) do obj:punch(...) end`

@ -71,7 +71,7 @@ local function test_entity_lifecycle(_, pos)
-- with binary in staticdata
local obj = core.add_entity(pos, "unittests:callbacks", "abc\000def")
assert(obj:is_valid())
assert(obj and obj:is_valid())
check_log({"on_activate(7)"})
obj:set_hp(0)