-- A usable Lua recursive table printer. local function tableprint(t, write, prefix, depth) if depth == nil then depth = 32 end if depth == 0 then write('...') return end if write == nil then write = io.write end if prefix == nil then prefix = '' end local iprefix = prefix..' ' if type(t) == 'table' then write('{\n') for k, v in pairs(t) do write(iprefix) if type(k) == 'string' and string.find(k, '^%w+$') then write(k) else write('[') tableprint(k, write, iprefix, depth-1) write(']') end write(' = ') tableprint(v, write, iprefix, depth-1) write(',\n') end write(prefix) write('}') elseif type(t) == 'string' then write(string.format('%q', t)) else write(t) end end tableprint({'okay', 'then', x = 5, {["you are"] = {}, 2.1, {{{{{{y=2, z=3}}}}}}}, [{}] = 5, [{}] = 6}) io.write('\n')