asdaa0

Params

Aug 23rd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. function debug.getparams(f)
  2. local co = coroutine.create(f)
  3. local params = {}
  4. debug.sethook(co, function()
  5. local i, k = 1, debug.getlocal(co, 2, 1)
  6. while k do
  7. if k ~= "(*temporary)" then
  8. table.insert(params, k)
  9. end
  10. i = i+1
  11. k = debug.getlocal(co, 2, i)
  12. end
  13. error("~~end~~")
  14. end, "c")
  15. local res, err = coroutine.resume(co)
  16. if res then
  17. error("The function provided defies the laws of the universe.", 2)
  18. elseif string.sub(tostring(err), -7) ~= "~~end~~" then
  19. error("The function failed with the error: "..tostring(err), 2)
  20. end
  21. return params
  22. end
Advertisement
Add Comment
Please, Sign In to add comment