Improve dumpTable function
This commit is contained in:
parent
d34c5204df
commit
9bd53b7e75
25
script.lua
25
script.lua
@ -9,16 +9,21 @@ TEXTURE_HEIGHT = 128
|
|||||||
--- Create a string representation of a table
|
--- Create a string representation of a table
|
||||||
--- @param o table
|
--- @param o table
|
||||||
function dumpTable(o)
|
function dumpTable(o)
|
||||||
if type(o) == 'table' then
|
if type(o) == 'table' then
|
||||||
local s = '{ '
|
local s = '{ '
|
||||||
for k,v in pairs(o) do
|
local first_loop=true
|
||||||
if type(k) ~= 'number' then k = '"'..k..'"' end
|
for k,v in pairs(o) do
|
||||||
s = s .. '['..k..'] = ' .. dumpTable(v) .. ','
|
if not first_loop then
|
||||||
end
|
s = s .. ', '
|
||||||
return s .. '} '
|
end
|
||||||
else
|
first_loop=false
|
||||||
return tostring(o)
|
if type(k) ~= 'number' then k = '"'..k..'"' end
|
||||||
end
|
s = s .. '['..k..'] = ' .. dumpTable(v)
|
||||||
|
end
|
||||||
|
return s .. '} '
|
||||||
|
else
|
||||||
|
return tostring(o)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param uv table
|
---@param uv table
|
||||||
|
Loading…
x
Reference in New Issue
Block a user