Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function printTable(t, tabs)
- local tabs = tabs and tabs + 1 or 0
- local initialTabs = tabs
- tabs = tabs + 1
- if not t then
- print("nil")
- return
- end
- local emptyTable = true
- for i,v in next,t do
- emptyTable = false
- break
- end
- if emptyTable or initialTabs == 0 then
- print(string.rep(" ", initialTabs)..(emptyTable and "{}"..(initialTabs > 0 and ";" or "") or "{"))
- end
- for i,v in next,t do
- if type(v) == "table" then
- if type(i) == "string" then
- print(string.rep(" ", tabs).."[\""..i.."\"] = {")
- else
- print(string.rep(" ", tabs)..tostring(i).." = {")
- end
- printTable(v, tabs+1)
- print(string.rep(" ", tabs).."};")
- else
- if type(i) == "string" then
- print(string.rep(" ", tabs).."[\""..i.."\"] =",tostring(v)..";")
- else
- print(string.rep(" ", tabs).."["..tostring(i).."] =",tostring(v)..";")
- end
- end
- end
- if initialTabs == 0 and not emptyTable then
- print("}")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment