mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Use numeric indices and raw table access with LUA_REGISTRYINDEX
This commit is contained in:
parent
34b7a147dc
commit
8658c8d9b5
7 changed files with 36 additions and 16 deletions
|
@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
ScriptApiBase *ModApiBase::getScriptApiBase(lua_State *L)
|
||||
{
|
||||
// Get server from registry
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "scriptapi");
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_SCRIPTAPI);
|
||||
ScriptApiBase *sapi_ptr = (ScriptApiBase*) lua_touserdata(L, -1);
|
||||
lua_pop(L, 1);
|
||||
return sapi_ptr;
|
||||
|
@ -49,7 +49,7 @@ GUIEngine *ModApiBase::getGuiEngine(lua_State *L)
|
|||
|
||||
std::string ModApiBase::getCurrentModPath(lua_State *L)
|
||||
{
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, SCRIPT_MOD_NAME_FIELD);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_CURRENT_MOD_NAME);
|
||||
const char *current_mod_name = lua_tostring(L, -1);
|
||||
if (!current_mod_name)
|
||||
return ".";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue