Jump to content
  • Advertisement
Sign in to follow this  
e-u-l-o-g-y

Lua globals in C(++)

This topic is 4829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!