Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ex = {
- hey = {
- nested_shit = {
- '1', '2', 3, function() end
- },
- print,
- },
- 2, 7,
- 'some random string',
- another_table = {
- newproxy(),
- 'even some userdata',
- {{{{{{'if you\'re seeing this this shit works'}}}}}}
- }
- }
- local function levelPrint(level, ...)
- io.write(string.rep('\t', level))
- print(...)
- end
- local function formatPair(first, second)
- if type(first) == 'string' then
- first = '"' .. first .. '"'
- end
- return string.format('[%s] = %s', tostring(first), tostring(second))
- end
- function inspect(list)
- local stack = {list}
- local info = {}
- local level = 1
- print('{')
- while #stack ~= 0 do
- local current = stack[#stack]
- local index, value = next(current, info[current])
- if not index then
- table.remove(stack, #stack)
- info[current] = nil
- level = level - 1
- levelPrint(level, '},')
- else
- info[current] = index
- if type(value) == 'string' then
- levelPrint(level, formatPair(index, '"' .. value .. '",'))
- elseif type(value) == 'table' then
- table.insert(stack, value)
- levelPrint(level, formatPair(index, '{'))
- level = level + 1
- else
- levelPrint(level, formatPair(index, value) .. ', ')
- end
- end
- end
- end
- function recursive_inspect(list, level)
- level = level or 0
- if level == 0 then
- print('{')
- end
- for index, value in pairs(list) do
- if type(value) == 'string' then
- levelPrint(level + 1, formatPair(index, '"' .. value .. '",'))
- elseif type(value) == 'table' then
- levelPrint(level + 1, formatPair(index, '{'))
- recursive_inspect(value, level + 1)
- else
- levelPrint(level + 1, formatPair(index, value) .. ',')
- end
- end
- levelPrint(level, '},')
- end
- recursive_inspect(ex)
- print('---')
- inspect(ex)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement