Can you please tell me how to transfer a pointer to an object from one function to another in LuaBridge?
using namespace luabridge; struct a { int x; a(int x) { this->x = x; cout << "call constructor with parameters\n" << endl; } void get() const /* время жизни lua.*/ {cout << x << endl; } ~a() { cout <<"desctor\n" << endl; } }; a* create(){ ab(56); return &b; } void pri(a *b, lua_State* L) { b->get(); } int main() { lua_State *L = luaL_newstate(); luaL_openlibs(L); getGlobalNamespace(L).addFunction("create", create) .addFunction("pri", pri); luaL_dofile(L, "main.lua"); lua_pcall(L, 0, 0, 0); }
ab(56); return &b;- oh-oh - int3