From 330ca90b8af24c1fdc56aab80809d0992c53a181 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Fri, 3 May 2013 23:59:09 +0000 Subject: extent for lua 5.2 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2981 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/lua/ULuaCore.pas | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/lua') diff --git a/src/lua/ULuaCore.pas b/src/lua/ULuaCore.pas index d1b6e7d2..a0398eb4 100644 --- a/src/lua/ULuaCore.pas +++ b/src/lua/ULuaCore.pas @@ -564,16 +564,17 @@ begin {**** replace the standard require with our custom require function } // first move standard require function to _require - lua_getfield(L, LUA_GLOBALSINDEX, PChar('require')); - lua_setfield(L, LUA_GLOBALSINDEX, PChar('_require')); + lua_getglobal(L, PChar('require')); + + lua_setglobal(L, PChar('_require')); // then save custom require function to require lua_pushcfunction(L, TLua_CustomRequire); - lua_setfield(L, LUA_GLOBALSINDEX, PChar('require')); + + lua_setglobal(L, PChar('require')); {**** now we create the usdx table } // at first functions from ULuaUsdx -// Function luaL_register is deprecated. Use luaL_setfuncs so that your module does not create globals. (Modules are not expected to set global variables anymore.) luaL_register(L, 'Usdx', @ULuaUsdx_Lib_f[0]); end; @@ -651,7 +652,6 @@ begin begin Id := lua_ToInteger(L, lua_upvalueindex(1)); -// Function luaL_register is deprecated. Use luaL_setfuncs so that your module does not create globals. (Modules are not expected to set global variables anymore.) luaL_register(L, PChar('Usdx.' + LuaCore.Modules[Id].Name), @LuaCore.Modules[Id].Functions[0]); // set the modules table as global "modulename" @@ -846,8 +846,7 @@ begin // we need at least one stack slot free lua_checkstack(State, 1); - // lua_getglobal(State, PChar(Name)); // this is just a macro: - lua_getfield(State, LUA_GLOBALSINDEX, PChar(Name)); + lua_getglobal(State, PChar(Name)); if (lua_isfunction(State, -1)) then begin // we got a function @@ -1015,7 +1014,7 @@ begin while (lua_getTop(L) >= 1) do begin // get luas require function - lua_getfield(L, LUA_GLOBALSINDEX, PChar('_require')); + lua_getglobal(L, PChar('_require')); // move it under the top param lua_insert(L, -2); -- cgit v1.2.3