diff options
Diffstat (limited to 'mesecons')
-rw-r--r-- | mesecons/util.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/mesecons/util.lua b/mesecons/util.lua index 39f5696..0a06401 100644 --- a/mesecons/util.lua +++ b/mesecons/util.lua @@ -151,6 +151,22 @@ function mesecon.tablecopy(table) -- deep table copy return newtable end +function mesecon.tablecopy_stripfunctions(table) -- deep table copy, but remove all functions + if type(table) == "function" then return nil end -- functions become nil + if type(table) ~= "table" then return table end -- no need to copy + local newtable = {} + + for idx, item in pairs(table) do + if type(item) == "table" then + newtable[idx] = mesecon.tablecopy(item) + elseif type(item) ~= "function" then + newtable[idx] = item + end + end + + return newtable +end + function mesecon.cmpAny(t1, t2) if type(t1) ~= type(t2) then return false end if type(t1) ~= "table" and type(t2) ~= "table" then return t1 == t2 end |