• Advertisement
Sign in to follow this  

Lua: Calling a function in a table

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