From c7c4b3d280d529909166ee2366b16f92dba1c953 Mon Sep 17 00:00:00 2001 From: grayswandir <grayswandir76@gmail.com> Date: Wed, 5 Nov 2014 23:56:50 -0500 Subject: [PATCH] Let table.check selectively not recurse. --- game/engines/default/engine/utils.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/game/engines/default/engine/utils.lua b/game/engines/default/engine/utils.lua index ca6d719d8b..ce72dd12fb 100644 --- a/game/engines/default/engine/utils.lua +++ b/game/engines/default/engine/utils.lua @@ -263,20 +263,21 @@ function table.removeFromList(t, ...) end end -function table.check(t, fct, path) - if path then path = path..'/' else path = '' end +function table.check(t, fct, do_recurse, path) + if path and path ~= '' then path = path..'/' else path = '' end + do_recurse = do_recurse or function() return true end for k, e in pairs(t) do local tk, te = type(k), type(e) - if te == "table" and not e.__CLASSNAME then - local ok, err = table.check(e, fct, path..tostring(k)) + if te == "table" and not e.__CLASSNAME and do_recurse(e) then + local ok, err = table.check(e, fct, do_recurse, path..tostring(k)) if not ok then return nil, err end else local ok, err = fct(t, path..tostring(k), e, te) if not ok then return nil, err end end - if tk == "table" and not k.__CLASSNAME then - local ok, err = table.check(k, fct, path..tostring(k)) + if tk == "table" and not k.__CLASSNAME and do_recurse(k) then + local ok, err = table.check(k, fct, do_recurse, path..tostring(k)) if not ok then return nil, err end else local ok, err = fct(t, path.."<key>", k, tk) -- GitLab