Howdy! Been struggling with this thing called Luabind now for quite a while, and I ain't understanding more now than I did before I even knew about it.
I have singleton classes that I want to expose to Lua. Here is how I am trying to expose my input library so key mappings can be done from Lua:
luabind::module(m_ptrLua, "GFW")
[
luabind::class_<InputLibrary>("InputLibrary")
.def("MapKey", &InputLibrary::mapKey)
.def("Instance", &InputLibrary::getInstance)
];
luabind::globals(m_ptrLua)["InputMap"] = InputLibrary::getInstance();
InputLibrary is my singleton class, and it contains many functions, but MapKey is the only one I'd like to expose to Lua. I am not sure whether I need the second .def for the singleton retrieval or not. The globals assignment is something I read on the Internet.
Here is how my script file looks like:
InputMap:MapKey("ESCAPE", "quit")
The script is run without errors, but the mapping of the key is never performed.. it is weird that it seems to work even though it doesn't.
What can I have missed? Do I have to make the luabind module thing inside the very class itself? Now I do it in the init() function of my script class, which is performed after the input library is created. The script file is executed one line before entering the main loop.