views:

229

answers:

1

I've made countless attempts to get this working, but everything I do gives me run-time errors. I've been trying to make asset managers to manage content for my game engine, and I'm using lua and luabind for my scripting. Getting everything to compile, binding classes and variables, and getting basic variables back from lua have been no problem so far.

My problem is I'm using an std::vector to store instances of my asset classes, and vectors don't seem to get along with luabind. I know I will need this vector because my C++ program will use it for rendering and other things

When I bind my manager class and the variables, (including the vector containing my asset classes) everything compiles and runs fine. In my lua script I can create new objects successfully, but when I try to access them, I get a run-time error.

To sum everything up:

I have a class that holds information for a game object or information about some other data.

I have another class that contains a vector of asset classes.

When I try to access this vector like I would a regular lua table, I get a run-time error.

So what should I do in C++ and luabind that will allow me to modify the classes in my asset manager class?

+1  A: 

You may need to bind the vector type itself with some relevant methods, or try Luabind's return_stl_iterator, which provides for iteration (but not indexing) over STL-compatible containers.

If you need more help, the code for your bindings and their types would be useful.

John Zwinck