Jump to content
  • Advertisement
Sign in to follow this  
Zipline1533

Lua: Calling a function in a table

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

I have used the lua code in Programming Gems 6 to integrate lua into my engine. All of my objects are basically a table with a pointer to the actual object. I can push the correct table to lua, but I can't seem to find a way to call the functions in the table from c++.

Share this post


Link to post
Share on other sites
Advertisement
You need to get the function from the table.

So push the table, push the key (function name), call gettable (to retrieve the function from the table). Now the function is on the stack and you can call it like a "normal" function.

Off the mind i don't remember if you have to put the parameters on the stack first, in that case you'll have to push them onto the stack before you retrieve the function.

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!