1
0
mirror of https://github.com/HybridDog/builtin_item.git synced 2025-11-21 01:25:23 +01:00

Fix crashes with objects in invalid state

If __builtin:item's on_step() makes the dropped item invalid, e.g. by
removing it, a later get_velocity() returns nil, which leads to a crash.

After this change, the overridden on_step() aborts early if the object
became invalid.
This commit is contained in:
HybridDog
2025-11-14 16:18:43 +01:00
parent c4a8ed4cd3
commit 3c45e98ff2

View File

@@ -76,8 +76,8 @@ item_entity.on_step = function(self, dtime, ...)
old_on_step(self, dtime, ...)
-- Ignore the item if it should not interact with physics
if not self.physical_state then
-- Ignore the item if it should not interact with physics or was removed
if not self.physical_state or not self.object:is_valid() then
return
end