Code: Select all
function util.merge(tables)
local ret = {}
for i, tab in ipairs(tables) do
for k, v in pairs(tab) do
if (type(v) == "table") and (type(ret[k] or false) == "table") then
ret[k] = util.merge{ret[k], v}
-- Suggested addition start
elseif type(v) == "table" then
ret[k] = table.deepcopy(v)
-- Suggested addition end
else
ret[k] = v
end
end
end
return ret
end