Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function print_r (t, name, indent)
- local tableList = {}
- function table_r (t, name, indent, full)
- local serial=string.len(full) == 0 and name
- or type(name)~="number" and '["'..tostring(name)..'"]' or '['..name..']'
- io.write(indent,serial,' = ')
- if type(t) == "table" then
- if tableList[t] ~= nil then io.write('{}; -- ',tableList[t],' (self reference)\n')
- else
- tableList[t]=full..serial
- if next(t) then -- Table not empty
- io.write('{\n')
- for key,value in pairs(t) do table_r(value,key,indent..'\t',full..serial) end
- io.write(indent,'};\n')
- else io.write('{};\n') end
- end
- else io.write(type(t)~="number" and type(t)~="boolean" and '"'..tostring(t)..'"'
- or tostring(t),';\n') end
- end
- table_r(t,name or '__unnamed__',indent or '','')
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement