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
scripting objects using tolua++
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
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?
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?
https://www.kbasm.com -- My personal website
https://github.com/wqking/eventpp eventpp -- C++ library for event dispatcher and callback list
https://github.com/cpgf/cpgf cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement