Lua and Luabind

Started by
5 comments, last by Eldritch 17 years ago
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.
Advertisement
Just found some info that Lua 5.1.1 (which I am using) does not work with Luabind 0.7 (which I am also using).. is this really true? Is there no later release for Luabind? Since Lua 5.0 is only supported on MSVC7 (according to the documentation, and also due to the fact I need LIBC.LIB, which does not exist in MSVC8) I seem to be in really deep trouble if I want this to work. Is there no solution?
Nothing?
You'll want to download Luabind from their SVN server, it is more up to date and works with Lua5.1 (thus it should work with 5.1.1).

As for Lua itself, download Luabinaries, either the source or bin distro. The source builds on VS05 with no problems (Well, the exe isn't set to depend on the libs so those builds will fail first time, but all the libs build just fine).

That should see you right...
That's right. The current version of Luabind in SVN is stable and works with Lua 5.1, it just hasn't had an official release yet. My project is staying with Lua 5.0 until they make that release.

Hero of Allacrost - A free, open-source 2D RPG in development.
Latest release June, 2015 - GameDev annoucement

We use Luabind SVN HEAD with Lua 5.1 and it works fine.
Should I use the code from the SVN trunk?

What should I do with the binaries? Does not make sense to me to use an executable..

This topic is closed to new replies.

Advertisement