Skip to content

Instantly share code, notes, and snippets.

@lunixbochs
Last active April 28, 2022 04:38
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lunixbochs/5b0bb27861a396ab7a86 to your computer and use it in GitHub Desktop.
Save lunixbochs/5b0bb27861a396ab7a86 to your computer and use it in GitHub Desktop.
local function string(o)
return '"' .. tostring(o) .. '"'
end
local function recurse(o, indent)
if indent == nil then indent = '' end
local indent2 = indent .. ' '
if type(o) == 'table' then
local s = indent .. '{' .. '\n'
local first = true
for k,v in pairs(o) do
if first == false then s = s .. ', \n' end
if type(k) ~= 'number' then k = string(k) end
s = s .. indent2 .. '[' .. k .. '] = ' .. recurse(v, indent2)
first = false
end
return s .. '\n' .. indent .. '}'
else
return string(o)
end
end
local function var_dump(...)
local args = {...}
if #args > 1 then
var_dump(args)
else
print(recurse(args[1]))
end
end
return var_dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment