lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm sorry if this response is useless or late, but I just wanted to test the mailing list. test.c: ------------------------------ #include const char m_TableName[]="GameObject"; main() { lua_State* VM=lua_open(); luaopen_base(VM); lua_dofile(VM, "test.lua"); /* copied from your message ..*/ // first get the table lua_pushstring(VM, m_TableName); // m_TableName = "GameObject" in this example lua_gettable(VM, LUA_GLOBALSINDEX); // get the 'init' function from the table lua_pushstring(VM, "init"); lua_gettable(VM, -2); // call the function /* first arg is the self */ lua_pushstring(VM, m_TableName); // m_TableName = "GameObject" in this example lua_gettable(VM, LUA_GLOBALSINDEX); lua_call(VM, 1, 0); return 0; } test.lua: ------------------------------ GameObject={_m="hi"}; function GameObject:init() print(self._m); end result: ------------------ $cc -o test test.c -llualib -llua $./test hi
 

Get your free email at http://www.crazyland.com