Better detection of properly serialized data
Remove entity if initialization data is missing. Downgrade message in that case to a warning.
This commit is contained in:
parent
d0d9600709
commit
7a5ee4e6e2
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue