Certainly use Zgoo, it helps a lot.
A note to your piece of code: debug.getlocal won't work. In ESO you only have access to math, string, table modules; debug, io, os, and I think coroutine as well, are disabled.
If you want to iterate over the global table, use zo_insecurePairs:
Lua Code:
for k, v in zo_insecurePairs(_G) do
...
end
This is because some functions in there cannot be accessed from add-ons, and regular pairs(_G) bails out when it comes across one.