summaryrefslogtreecommitdiff
path: root/mesecons_luacontroller
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-05-12 18:48:23 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-05-12 18:48:23 -0400
commit0f313120fe54fbd6bc4a3eccf5caaad7faa97001 (patch)
tree50c27cd09008b05225d2de6f23808c36eae22af8 /mesecons_luacontroller
parentec3d07f8296dce357f7147a4c834a97329d1ef11 (diff)
downloaddreambuilder_modpack-0f313120fe54fbd6bc4a3eccf5caaad7faa97001.tar
dreambuilder_modpack-0f313120fe54fbd6bc4a3eccf5caaad7faa97001.tar.gz
dreambuilder_modpack-0f313120fe54fbd6bc4a3eccf5caaad7faa97001.tar.bz2
dreambuilder_modpack-0f313120fe54fbd6bc4a3eccf5caaad7faa97001.tar.xz
dreambuilder_modpack-0f313120fe54fbd6bc4a3eccf5caaad7faa97001.zip
updated castle, colormachine, homedecor, mesecons, pipeworks, signs_lib, technic, and xban2
Diffstat (limited to 'mesecons_luacontroller')
-rw-r--r--mesecons_luacontroller/init.lua30
1 files changed, 21 insertions, 9 deletions
diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua
index e669f93..01f5878 100644
--- a/mesecons_luacontroller/init.lua
+++ b/mesecons_luacontroller/init.lua
@@ -229,23 +229,35 @@ end
local function remove_functions(x)
local tp = type(x)
- if tp == "table" then
+ if tp == "function" then
+ return nil
+ end
+
+ -- Make sure to not serialize the same table multiple times, otherwise
+ -- writing mem.test = mem in the LuaController will lead to infinite recursion
+ local seen = {}
+
+ local function rfuncs(x)
+ if seen[x] then return end
+ seen[x] = true
+ if type(x) ~= "table" then return end
+
for key, value in pairs(x) do
- local key_t, val_t = type(key), type(value)
- if key_t == "function" or val_t == "function" then
+ if type(key) == "function" or type(value) == "function" then
x[key] = nil
else
- if key_t == "table" then
- remove_functions(key)
+ if type(key) == "table" then
+ rfuncs(key)
end
- if val_t == "table" then
- remove_functions(value)
+ if type(value) == "table" then
+ rfuncs(value)
end
end
end
- elseif tp == "function" then
- return nil
end
+
+ rfuncs(x)
+
return x
end