Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Lua and Methods

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

Hello- From the reading I''ve done, Lua seems very function-centric. Calling my C++ functions from Lua is no problem, but calling a class method seems impossible. lua_register simply doesn''t accept pointers to class methods. From what I can tell, luabind is much for being able to declare C++ objects within your Lua script, but I simply need to register a class method to be called from within my Lua script. Any help is much appreciated-

Share this post

Link to post
Share on other sites
ever tried to make a function pointer to a class member function?
-> won''t work (unless using tricks like functors)

so you could make something like:

class someclass
void wantthat();

void callwantthat(lua_state *l)

this won''t compile with 99% probability as it was typed off my head and function names/parameters, especially of toUserdata(), are wrong, but i hope you get the idea.

you could also look at tolua/luabind how they do it (if they can) but i have not used them so i can''t really tell.

Share this post

Link to post
Share on other sites

  • 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!