Renamed file and minor cleanup.
This commit is contained in:
parent
a8d408f375
commit
3e452992c8
@ -1,9 +1,9 @@
|
|||||||
-- Print anything - including nested tables
|
-- Print anything - including nested tables
|
||||||
-- Based on but modified from:
|
-- Based on but modified from:
|
||||||
-- http://lua-users.org/wiki/TableSerialization
|
-- http://lua-users.org/wiki/TableSerialization
|
||||||
module("printTable", package.seeall)
|
module("TablePrinter", package.seeall)
|
||||||
|
|
||||||
function printTable.printTable (tt, indent, done)
|
function TablePrinter.print (tt, indent, done)
|
||||||
done = done or {}
|
done = done or {}
|
||||||
indent = indent or 0
|
indent = indent or 0
|
||||||
if tt == nil then
|
if tt == nil then
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
-- Print anything - including nested tables
|
|
||||||
-- Based on but modified from:
|
|
||||||
-- http://lua-users.org/wiki/TableSerialization
|
|
||||||
function printTable (tt, indent, done)
|
|
||||||
done = done or {}
|
|
||||||
indent = indent or 0
|
|
||||||
if tt == nil then
|
|
||||||
io.write("nil\n")
|
|
||||||
else
|
|
||||||
if type(tt) == "table" then
|
|
||||||
for key, value in pairs (tt) do
|
|
||||||
io.write(string.rep (" ", indent)) -- indent it
|
|
||||||
if type (value) == "table" and not done [value] then
|
|
||||||
done [value] = true
|
|
||||||
io.write(string.format("[%s] => table\n", tostring (key)));
|
|
||||||
io.write(string.rep (" ", indent+4)) -- indent it
|
|
||||||
io.write("(\n");
|
|
||||||
table_print (value, indent + 7, done)
|
|
||||||
io.write(string.rep (" ", indent+4)) -- indent it
|
|
||||||
io.write(")\n");
|
|
||||||
else
|
|
||||||
io.write(string.format("[%s] => %s\n",
|
|
||||||
tostring (key), tostring(value)))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
io.write(tt .. "\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
x
Reference in New Issue
Block a user