• Advertisement
Sign in to follow this  

scripting objects using tolua++

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

Hi guys..
I m trying to write a lua script that will manage some of the objects in my game. Right now I m focusing on controlling the camera through lua. 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
{
public:
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
Advertisement
Basically what I want to do is : try and access the createCamera function of ogre which is declared in OgreSceneManager.h in my lua script so that I can manage my objects using lua

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
Sign in to follow this  

  • Advertisement