Lua and Methods
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-
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:
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.
-> won''t work (unless using tricks like functors)
so you could make something like:
class someclass{ void wantthat();};void callwantthat(lua_state *l){ ((someclass)l->toUserdata(l,1))->wantthat();}
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.
http://mitglied.lycos.de/lousyphreak/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement