开发者

How do I use Luabind and C++ to create an asset managing class?

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 开发者_JAVA技巧my asset manager class?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜