sending c variables to lua
Posted: Mon Jun 14, 2010 8:09 pm
ok here is the situation. i am using luabridge because it is very nice and small. it allows me to export class definitions to lua but i want to pass the class variables to lua.
i have been reading about the stack and the doc is not very clear, i have been working with lua_newuserdata, luaL_getmetatable, and lua_setmetatable for about 4 hours now and im getting nowhere. i want to create a function to create a global variable in lua. here is the abstract code( what i want it to look like )
in lua
now test will be in lua and in c++ is there any way to do this, cause i know i can do this in luabind but its huge and uses boost so i want to stay away from it.
thanks for any info you can give. im going to go look for more resources lol
i have been reading about the stack and the doc is not very clear, i have been working with lua_newuserdata, luaL_getmetatable, and lua_setmetatable for about 4 hours now and im getting nowhere. i want to create a function to create a global variable in lua. here is the abstract code( what i want it to look like )
Code: Select all
Test test;
Mgr->SetGlobal("test", &test);
std::cout << test.getX() << std::endl; // output = 0;
Mgr->DoFile("test.lua"); // just a wrapper for luaL_dofile
std::cout << test.getX() << std::endl; // output = 4;
Code: Select all
test:setX(4)
now test will be in lua and in c++ is there any way to do this, cause i know i can do this in luabind but its huge and uses boost so i want to stay away from it.
thanks for any info you can give. im going to go look for more resources lol