krom

Test

Mar 15th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.35 KB | None | 0 0
  1. local test = 'testset'
  2.  
  3. function locals()
  4.   local variables = {}
  5.   local idx = 1
  6.   while true do
  7.     local ln, lv = debug.getlocal(2, idx)
  8.     if ln ~= nil then
  9.       variables[ln] = lv
  10.     else
  11.       break
  12.     end
  13.     idx = 1 + idx
  14.   end
  15.   return variables
  16. end
  17.  
  18.  
  19. local function foo()
  20.     local bar = 'bar'
  21.     print(locals())
  22. end
  23.  
  24. foo()
Advertisement
Add Comment
Please, Sign In to add comment