I want to include Lua-Scripting (Lua 5.1) in a Delphi application. For this I use Thomas Laverne header files.
Now I am trying to register the userdata type following this example: http://www.lua.org/pil/28.2.html
The "new array function" uses the * luaL_getmetatable * command.
static int newarray (lua_State *L) { int n = luaL_checkint(L, 1); size_t nbytes = sizeof(NumArray) + (n - 1)*sizeof(double); NumArray *a = (NumArray *)lua_newuserdata(L, nbytes); luaL_getmetatable(L, "LuaBook.array"); lua_setmetatable(L, -2); a->size = n; return 1; }
Unfortunately, the * luaL_getmetatable * function is marked as old in my header file and commented out. I tried activating it again, but as expected, I will get an error because the dll entry point was not found.
This is a Delphi translation of this example (using a different data type without an array)
Type tMyType = tWhatever; pMyType = ^tMyType; {...} Function newusertype(aState : pLua_State) : LongInt; cdecl; Var NewData : pMyType; Begin Result := 0; NewData := lua_newuserdata(aState, SizeOf(tMyType )); NewData^ := GetInitValue; luaL_getMetaTable(aState, 'myexcample.mytype');
Now I am looking for a replacement for luaL_getMetaTable. I did not find any information about this. In fact, I did not find any information that luaL_getMetaTable is out of date, but it looks like this: (.
source share