Note that there are some explanatory texts on larger screens.

plurals
  1. POreplacement for luaL_getMetaTable
    text
    copied!<p>I want to enable Lua-Scripting (Lua 5.1) in my Delphi application. For this purpose I use the header Files of Thomas Lavergne.</p> <p>Now I try to register a userdata type following this example: <a href="http://www.lua.org/pil/28.2.html" rel="nofollow">http://www.lua.org/pil/28.2.html</a></p> <p>At the "new array function" it uses the command *luaL_getmetatable*.</p> <pre><code>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-&gt;size = n; return 1; /* new userdatum is already on the stack */ } </code></pre> <p>Unfortunately the *luaL_getmetatable* Function is marked al old at my header File and commented out. I tried to activate it again but as expected I will get an error because the dll entrancepoint couldn't be found.</p> <p>This is the Delphi-translation of that example (using another non array datatype)</p> <pre><code>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'); // Error/unknown function lua_setmetatable(aState, -2); Result := 1; End; </code></pre> <p>Now I'm looking for an replacement of luaL_getMetaTable. I haven't found any information about one. In fact I haven't found any information that luaL_getMetaTable is outdated but it seems to be :(.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload