Sign in to follow this  

scripting objects using tolua++

Recommended Posts

Hi guys..
I m trying to write a lua script that will manage some of the objects in my game. Right now I m[b] focusing on controlling the camera[/b] [b]through lua[/b]. I' m using tolua++ to generate the bindings. I m using Ogre as the Graphics library. So I m having 2 classes.
Class MyScene and Class BaseScene
MyScene is a child class of BaseScene and BaseScene has the data member OgreSceneMgr which is of type Ogre::SceneManager*

class MyScene : public BaseScene
void InitializeScene(); // is one of the functions in my class

So what I want to do is in the InitializeScene function, I want to create a camera.

Now ideally I can do it in C++ using pMyCam = OgreSceneMgr->createCamera()

But how do I call this createCamera function in my luascript because using tolua++ I exposed the MyScene class and all its public functions and since BaseScene class is the parent, it should also expose its function which it did not for me because I was getting an error when i executed lua_call function.

I wrote a wrapper and it worked perfectly but that would defeat the purpose of scripting wouldnt it? I actually went through the OgreSceneManager.h and tried to create a package file out of it but then it gives me compiler errors

Share this post

Link to post
Share on other sites
I can't help with your question because I never used tolua++.

But if I was choosing binding library, I would prefer non parser solution to parser one.
The reason is simple, C++ is so complicated, a simple parse can't handle every C++ header. That's why tolua++ (also SWIG?) requires "clean" header.

And the parser solution gives your very few freedom.

Is it too late for you to choose another library?

For your question, if tolua++ can't handle that function, can you bind it with raw Lua API?

Share this post

Link to post
Share on other sites
I can bind the function only if i create its wrapper because the function will need a pointer to the Lua Virtual Machine as one of its arguments. So i will have to create a wrapper if I want to bind it with raw Lua API. Its just I wanted to reduce the C++ code and put more code on the lua side for doing object modification

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this