Posted 19 February 2013 - 10:07 AM
So basically i just forget how to print out entire tables, like for miscperipherals i want to print out m.list() but its a table and i forget what to do to print that out, can anyone help?
textutils.serialize()
which will return a string, or you can use
for index, param in pairs(table) do
print(index..": "..tostring(param))
end
for k, v in pairs(tableVariable) do
print(tostring(k)..": "..tostring(v))
end
function dump(t, level)
level = level or 0
for i,v in pairs(t) do
io.write(string.rep(' ', level))
io.write(i..': ')
if type(v) == 'table' then
print ''
dump(v, level + 1)
else
print(tostring(v))
end
end
end
local thing = {
a_table = {
another_table = {
some_value = 'a string'
}
}
}
dump(thing)
for k, v in pairs(tableVariable) do print(tostring(k)..": "..tostring(v)) end
Edit to respond to the post above which was submitted while I was writing my reply: You need to tostring both the key and the value, because boolean true and false are acceptable table keys. Table serialization does not also print the table, and is not designed to be pleasant for humans to read.