nSun

var_dump

Jul 23rd, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.47 KB | None | 0 0
  1. function var_dump(v,pad)
  2.   pad = pad or ""
  3.   local _t = type(v)
  4.   if _t=="table" then
  5.     local _k,_v
  6.     local _r = ""
  7.     for _k,_v in pairs(v) do
  8.       _r = _r..pad.."  ".._k.."="..var_dump(_v,pad.."  ")..",\n"
  9.     end
  10.     if string.len(_r)>0 then
  11.       return "{\n".._r..pad.."}"
  12.     else
  13.       return "{}"
  14.     end
  15.   elseif _t=="function" then
  16.     return "function()"
  17.   elseif _t=="string" then
  18.     return "\""..v.."\""
  19.   else
  20.     return tostring(v)
  21.   end
  22. end
Add Comment
Please, Sign In to add comment