# 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.

## 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 on other sites
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?

##### 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 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 on other sites
We use Luabind SVN HEAD with Lua 5.1 and it works fine.

##### 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..

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 14
• 9
• 10
• 12
• 17
• ### Forum Statistics

• Total Topics
632907
• Total Posts
3009162
• ### Who's Online (See full list)

There are no registered users currently online

×