From 7a5ee4e6e28133acac7d4ca402e8bf304191caf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20R=C3=BChle?= Date: Sun, 3 Mar 2024 22:34:29 +0100 Subject: [PATCH] Better detection of properly serialized data Remove entity if initialization data is missing. Downgrade message in that case to a warning. --- mods/ITEMS/mcl_chests/api.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_chests/api.lua b/mods/ITEMS/mcl_chests/api.lua index c98050934..42e0a901d 100644 --- a/mods/ITEMS/mcl_chests/api.lua +++ b/mods/ITEMS/mcl_chests/api.lua @@ -106,10 +106,12 @@ minetest.register_entity("mcl_chests:chest", { end, on_activate = function(self, initialization_data) - if initialization_data:find("^return") then + if initialization_data and initialization_data:find("\"###mcl_chests:chest###\"") then self:initialize(unpack(minetest.deserialize(initialization_data))) else - minetest.log("warning", debug.traceback("[mcl_chests] on_activate called without initialization_data")) + minetest.log("warning", + "[mcl_chests] on_activate called without proper initialization_data ... removing entity") + self.object:remove() end end, @@ -147,7 +149,7 @@ local function create_entity(pos, node_name, textures, param2, double, sound_pre entity_pos) dir, entity_pos = get_entity_info(pos, param2, double, dir, entity_pos) local initialization_data = minetest.serialize({pos, node_name, textures, dir, double, sound_prefix, - mesh_prefix, animation_type}) + mesh_prefix, animation_type, "###mcl_chests:chest###"}) local obj = minetest.add_entity(entity_pos, "mcl_chests:chest", initialization_data) if obj and obj:get_pos() then return obj:get_luaentity()