Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function printTable(tbl)
- print("{")
- printTableIndex(tbl, "\t", {})
- print("}")
- end
- function printTableIndex(tbl, before, alreadyUsed)
- for i, v in pairs(tbl) do
- if type(v) == "table" then
- if tableContainsValue(alreadyUsed, v) then
- print(before .. i .. ":", "alreadyUsed");
- else
- print(before .. i .. ": {");
- table.insert(alreadyUsed, v)
- printTableIndex(v, before .. "\t", alreadyUsed)
- print(before .. "}")
- end
- else
- print(before .. i .. ":", v);
- end
- end
- end
- function tableContainsValue(table, value)
- for i, v in pairs(table) do
- if v == value then return true end
- end
- return false
- end
- return {
- printTable=printTable
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement