-2

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!

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Nataly
  • 15
  • 2
  • 1
    Maybe [this](http://stackoverflow.com/questions/22515908/using-straight-lua-how-do-i-expose-an-existing-c-class-objec-for-use-in-a-lua/22558439#22558439) will help – W.B. Aug 04 '14 at 17:30
  • 1
    much easier: [luabridge](http://vinniefalco.com/LuaBridge/Manual.html) (no boost), [luabind](http://www.rasterbar.com/products/luabind.html) using boost – Dmitry Ledentsov Aug 04 '14 at 17:49

1 Answers1

0

"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.

Mijago
  • 1,569
  • 15
  • 18