lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi
 
Thanks for the replies
Nope it wasn't the globals that I wanted to see, it was the contents of the Lua Registry.
 
Rena's reply was exactly what I needed,  nice and simple too, just a one liner.  My Googling somehow managed to miss debug.getregistry ().
 
Thanks again 
   Geoff
 
 
> Date: Tue, 26 Nov 2013 00:28:41 +0000
> From: cathalgarvey@cathalgarvey.me
> To: lua-l@lists.lua.org
> Subject: Re: Question about Lua Registry
>
> Hey Geoff,
> If I understand the question correctly, you want to see the keys/values
> of all global variables in lua?
>
> If so:
> for key, val in pairs(_G) do
> print(key,val)
> end
>
> Obviously "val" will be rendered unsatisfyingly in cases of tables and
> functions, but it'll give you an idea of what's there, at least. You
> could do a check for tables and have a sub-loop to iterate through
> those, if you liked..
>
> On Tue, 26 Nov 2013 00:15:01 +0000
> Geoff Smith <spammealot1@live.co.uk> wrote:
>
> > Hi
> >
> > Bit of a newbie type question I am afraid
> >
> > For the purposes of a debugging aid, is it possible to iterate
> > through and print out the contents of the Lua registry from a) pure
> > Lua code, and b) from C using the C API ? I am guessing b) is
> > possible but I cant find any example code or mention of this so I am
> > wondering if that statement is actually true ? Thanks for any guidance
> >
> > Regards Geoff
> >