lua-users home
lua-l archive

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


On Dec 22, 2007 1:32 PM, Lionel Fumery <lif-ml@mindtwist.com> wrote:
> Hello,
>
> I use the following code to create global variables :
>     lua_pushnumber(m_LUA, Value);
>     lua_setglobal(m_LUA, VarName);
>
> Is there a way to find / list / enumerate all those global variables,
> without knowing their name ?
>
> Thank you for your help,
>
> LiF.
>
>

Look into the lua_next API function, and use it with the
LUA_GLOBALSINDEX pseudo-index.

Alternatively if you want to get at them from inside a Lua script,
look into the pairs() function and the global variable _G, which is a
convenient reference to the globals table.