|
8 | 8 | ]]-- |
9 | 9 | SPACES_PER_TAB = 2 |
10 | 10 |
|
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 |
12 | 13 | local loop |
13 | 14 | local typeof = typeof or type |
14 | 15 | 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) |
129 | 130 | table.insert(out, formatstring(tostring(v))) |
130 | 131 | table.insert(out, " (*** cycle table reference detected ***)\"") |
131 | 132 | else |
132 | | - table.insert(out, export(v, forcedictlayout, beautify, tabs + 1)) |
| 133 | + table.insert(out, export(v, forcedictlayout, beautify, tabs + 1, max_depth)) |
133 | 134 | end |
134 | 135 | elseif typeof(v) == "boolean" then |
135 | 136 | table.insert(out, tostring(v)) |
@@ -160,4 +161,4 @@ function export(tabl, forcedictlayout, beautify, tabs) |
160 | 161 | table.insert(out, "}") |
161 | 162 | return table.concat(out) |
162 | 163 | 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