Skip to content

Commit 07ce502

Browse files
authored
Update TableSerializer.lua
1 parent 2c07cd9 commit 07ce502

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

TableSerializer.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
]]--
99
SPACES_PER_TAB = 2
1010

11-
function export(tabl, forcedictlayout, beautify, tabs)
11+
function export(tabl, forcedictlayout, beautify, tabs, max_depth)
12+
if tabs and max_depth and tabs > max_depth then return "Reached max depth" end
1213
local loop
1314
local typeof = typeof or type
1415
if typeof(tabl) ~= "table" then return error("Argument 1 should be of type 'table'.") end
@@ -129,7 +130,7 @@ function export(tabl, forcedictlayout, beautify, tabs)
129130
table.insert(out, formatstring(tostring(v)))
130131
table.insert(out, " (*** cycle table reference detected ***)\"")
131132
else
132-
table.insert(out, export(v, forcedictlayout, beautify, tabs + 1))
133+
table.insert(out, export(v, forcedictlayout, beautify, tabs + 1, max_depth))
133134
end
134135
elseif typeof(v) == "boolean" then
135136
table.insert(out, tostring(v))
@@ -160,4 +161,4 @@ function export(tabl, forcedictlayout, beautify, tabs)
160161
table.insert(out, "}")
161162
return table.concat(out)
162163
end
163-
return function(tabl, ForceDictLayout, Beautify) return export(tabl, ForceDictLayout, Beautify) end
164+
return function(tabl, ForceDictLayout, Beautify, maxdepth) return export(tabl, ForceDictLayout, Beautify, maxdepth) end

0 commit comments

Comments
 (0)