Jump to content
  • Advertisement
Sign in to follow this  
DrEvil

Lua : dump global info?

This topic is 5472 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

Hey everyone, I'm wondering if it may be possible to retrieve an entire list of functions/variables registered with lua. As an example, suppose I have a game that exposes a bunch of functionality to lua, is there a built in lua method or similar that can loop through and print out all the function names that have been registered or would I need to do this in some way on my own? Thanks J

Share this post


Link to post
Share on other sites
Advertisement
All global functions and variables in lua are in the _G table. So if you loop through that dumping all the functions in that you'll get the list you want.

Share this post


Link to post
Share on other sites
uaing this code


print('_G size: ' .. table.getn(_G));
for i=1, 10 do
print(_G);
end



I get this output _G size: 0
and 10 lines of nil.

This is after I bind functions and define a few global functions. Shouln't this print those out? What am I doing wrong?

Thanks
J

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!