dump = {} dump.depth = 0 dump._string = function(s) return string.format("%q", s) end dump._number = function(n) return tonumber(n) end dump._boolean = function(b) if (b) then return "true" end return "false" end dump._userdata = function(u) return "" end dump._function = function(f) return "" end dump._nil = function(n) return "nil" end dump._thread = function(t) return "" end dump._lightuserdata = function(l) return "" end dump._table = function(t) local buf = '' if (dump.depth > 0) then buf = buf .. '{\n' end dump.depth = dump.depth + 1; for k,v in pairs(t) do buf = buf..string.format('%s[%s] = %s;\n', string.rep("\t", dump.depth - 1), dump["_" .. type(k)](k), dump["_" .. type(v)](v)) end dump.depth = dump.depth - 1; if (dump.depth > 0) then buf = buf .. string.rep("\t", dump.depth - 1) .. '}' end return buf end