Menu
  • HOME
  • TAGS

Cannot get a Lua function to reference 'self'

c++,lua,lua-5.2,luabridge

I managed to fix the problem. I added the self as an extra argument in the listener constructor and passed it as the first parameter to the callback function. -- in the script self.Callback = LuaCallback(self, self.printName) Helper.setCallback(self.Callback) ...

Get n-th element from end of list (table)

arrays,list,lua,lua-table,lua-5.2

Try list[#list+1-n] to get the n-th entry, counting from 1 as usual in Lua. So the last item has n=1.

How to store a value type in a userdata?

c++,c,lua,lua-5.2

First, for helloworld your code works: /* file: hw.c * on Debian/Ubuntu compile with: * `gcc -I/usr/include/lua5.2 -fpic -shared -o hw.so hw.c` */ #include <lua.h> #include <lauxlib.h> struct SomethingWrapper { void *object; }; static int l_helloworld(lua_State *L) { lua_pushliteral(L, "Hello World!"); return 1; } static luaL_Reg const some_funcs[] = {...

Porting from Lua 5.1 to 5.2

c#,c++,lua,porting,lua-5.2

I believe I've managed to upgrade this, so I'll add the details of what I did below and the conversion. I created a C wrapper into the LUA lower level API to export the functionality I needed: 1a) Replaced lua_settable(luaState, LUA_REGISTRYINDEX); // LUA_REGISTRYINDEX no longer accessible 1b) With lua_settablereg(luaState); 2a)...