Lua globals in C(++)

Started by
1 comment, last by e-u-l-o-g-y 18 years, 7 months ago
Hi! I'm currently starting to test out lua for my game engine, but I've run into a problem. How can I iterate over all the global variables in a lua_State in C++? Thanks :)
my-eulogy - A blog about coding and gfxsdgi - Semi-Daily Game IdeaChunkyHacker - Viewer for Relic chunky formats (used in DOW)
Advertisement
Global variables simply make up a Lua table, one which is located at the lua stack pseudoindex LUA_GLOBALS (that might not be exactly the right name... check the reference manual). So just iterate over that the way you would iterate over any table.
Thanks! I was just not thinking about the fact that I can use the LUA_GLOBALSINDEX directly in the lua_next function, but thought I had to use lua_gettable first :P
my-eulogy - A blog about coding and gfxsdgi - Semi-Daily Game IdeaChunkyHacker - Viewer for Relic chunky formats (used in DOW)

This topic is closed to new replies.

Advertisement