Jump to content
  • Advertisement
Sign in to follow this  
Eldritch

Lua and Luabind

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

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
Sign in to follow this  

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