Can we use Lua inside a cpp cocos project?

Can we use Lua inside a cpp cocos project?
0.0 0


Hey guys!

I am trying to call some lua scripts from inside a cpp project. Is that possible? And if yes, can anyone tell me what all things have to be done (I am guessing we need to add some more libraries and dependencies) and a sample ‘hello world’ routine for the same? (The cpp project calls a lua function which returns a "Hello World’ string and we draw it on the screen).

Also, I don’t need all the cocos bindings in that. I don’t intend Lua to interact with cocos. I just need Lua for gameplay scripting, for example, for defining AI behavior etc. So I just want to know, is that possible, to connect lua with the cpp cocos project to exchange some values?


Anyone knows?


You can add a lua-script to Node.

auto player = Sprite::create("player.png");

auto luaComponent = ComponentLua::create("player.lua");


But that allows only 3 functions: onEnter, onExit, update. What if I want to call some other C++ function from Lua or vice-versa?


I blogged about this a while ago at

See if that helps?!