Add dumptable for debuggings
This commit is contained in:
25
DumpTable.lua
Normal file
25
DumpTable.lua
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
---@type HeimdallData
|
||||||
|
local _, data = ...
|
||||||
|
|
||||||
|
if not data.dumpTable then
|
||||||
|
---@param table table
|
||||||
|
---@param depth number?
|
||||||
|
data.dumpTable = function(table, depth)
|
||||||
|
if not table then print(tostring(table)) return end
|
||||||
|
if depth == nil then
|
||||||
|
depth = 0
|
||||||
|
end
|
||||||
|
if (depth > 200) then
|
||||||
|
print("Error: Depth > 200 in dumpTable()")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for k, v in pairs(table) do
|
||||||
|
if (type(v) == "table") then
|
||||||
|
print(string.rep(" ", depth) .. k .. ":")
|
||||||
|
DumpTable(v, depth + 1)
|
||||||
|
else
|
||||||
|
print(string.rep(" ", depth) .. k .. ": ", v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user