Using C++ objects in Lua scripts

250 Views Asked by At

How I can use C++ objects in lua script?

example class:

class cMyClass
{
 int a;
 void myTest(int b){};
}

cMyClass MyObject;

example using in lua(is what i need):

MyObjectLuaName.myTest(7);
MyObjectLuaName.a=12;

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

"Use C++ Objects in Lua" - for me that shouts for an "userdata" object!

http://loadcode.blogspot.de/2007/02/wrapping-c-classes-in-lua.html (this one is nice) http://rubenlaguna.com/wp/2012/12/09/accessing-cpp-objects-from-lua/

That does exactly what you need.