From e7cba4071b9720ced276ad2b03e9b31a5ad9ab59 Mon Sep 17 00:00:00 2001 From: savilli <78875209+savilli@users.noreply.github.com> Date: Sat, 16 Sep 2023 18:19:03 +0200 Subject: [PATCH] Fix crash if add_entity fails (#88) --- luaentity.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/luaentity.lua b/luaentity.lua index 9baea55..ef6d552 100644 --- a/luaentity.lua +++ b/luaentity.lua @@ -163,11 +163,15 @@ local entitydef_default = { if not is_active(entity_pos) then return end - local ent = minetest.add_entity(entity_pos, entity.name):get_luaentity() + local object = minetest.add_entity(entity_pos, entity.name) + if not object then + return + end + local ent = object:get_luaentity() ent:from_data(entity.data) ent.parent_id = self._id ent.attached_id = index - entity.entity = ent.object + entity.entity = object local master = self._attached_entities_master if master then self:_attach(index, master)