From 4962d44be940e8a1cb90a5b3ada9714b650f16ad Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Fri, 19 Jun 2020 11:25:37 +0100 Subject: [PATCH] tweak staticdata checks --- api.lua | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/api.lua b/api.lua index ea409fd..e3edf57 100644 --- a/api.lua +++ b/api.lua @@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi") mobs = { mod = "redo", - version = "20200616", + version = "20200619", intllib = S, invis = minetest.global_exists("invisibility") and invisibility or {} } @@ -3022,7 +3022,9 @@ function mob_class:mob_staticdata() local t = type(stat) - if t ~= "function" and t ~= "nil" and t ~= "userdata" + if t ~= "function" + and t ~= "nil" + and t ~= "userdata" and _ ~= "_cmi_components" then tmp[_] = self[_] end @@ -3063,8 +3065,16 @@ function mob_class:mob_activate(staticdata, def, dtime) local tmp = minetest.deserialize(staticdata) if tmp then + for _,stat in pairs(tmp) do - self[_] = stat + + local t = type(stat) + + if t ~= "function" + and t ~= "nil" + and t ~= "userdata" then + self[_] = stat + end end end @@ -3945,7 +3955,7 @@ function mobs:register_arrow(name, def) self:hit_mob(player) - self.object:remove() ; --print("hit mob") + self.object:remove() ; --print("hit mob") return end @@ -3958,7 +3968,7 @@ function mobs:register_arrow(name, def) self:hit_object(player) - self.object:remove(); -- print("hit object") + self.object:remove() ; -- print("hit object") return end @@ -4144,7 +4154,6 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) return itemstack end, }) - end @@ -4160,7 +4169,9 @@ function mobs:force_capture(self, clicker) local t = type(stat) - if t ~= "function" and t ~= "nil" and t ~= "userdata" then + if t ~= "function" + and t ~= "nil" + and t ~= "userdata" then tmp[_] = self[_] end end