aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2015-08-25 07:00:56 +0200
committerest31 <MTest31@outlook.com>2015-08-27 01:56:06 +0200
commit8658c8d9b5f30dc952eed29a19d619de9210474c (patch)
treea9f6e6d48d0ac1b3a0d9a566e99a3d74dac63e22 /src/script/lua_api
parent34b7a147dcf9831f3b4d81599c473ba01ff5da00 (diff)
downloadminetest-8658c8d9b5f30dc952eed29a19d619de9210474c.tar.gz
minetest-8658c8d9b5f30dc952eed29a19d619de9210474c.tar.bz2
minetest-8658c8d9b5f30dc952eed29a19d619de9210474c.zip
Use numeric indices and raw table access with LUA_REGISTRYINDEX
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_base.cpp4
-rw-r--r--src/script/lua_api/l_server.cpp4
-rw-r--r--src/script/lua_api/l_util.cpp4
3 files changed, 6 insertions, 6 deletions
diff --git a/src/script/lua_api/l_base.cpp b/src/script/lua_api/l_base.cpp
index 6ad3e4ba2..515a7d933 100644
--- a/src/script/lua_api/l_base.cpp
+++ b/src/script/lua_api/l_base.cpp
@@ -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 ".";
diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp
index 73eca9d60..a6dac487b 100644
--- a/src/script/lua_api/l_server.cpp
+++ b/src/script/lua_api/l_server.cpp
@@ -345,7 +345,7 @@ int ModApiServer::l_show_formspec(lua_State *L)
int ModApiServer::l_get_current_modname(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
- lua_getfield(L, LUA_REGISTRYINDEX, SCRIPT_MOD_NAME_FIELD);
+ lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_CURRENT_MOD_NAME);
return 1;
}
@@ -442,7 +442,7 @@ int ModApiServer::l_notify_authentication_modified(lua_State *L)
int ModApiServer::l_get_last_run_mod(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
- lua_getfield(L, LUA_REGISTRYINDEX, SCRIPT_MOD_NAME_FIELD);
+ lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_CURRENT_MOD_NAME);
const char *current_mod = lua_tostring(L, -1);
if (current_mod == NULL || current_mod[0] == '\0') {
lua_pop(L, 1);
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp
index 12146e80a..4b8b6d351 100644
--- a/src/script/lua_api/l_util.cpp
+++ b/src/script/lua_api/l_util.cpp
@@ -371,7 +371,7 @@ int ModApiUtil::l_request_insecure_environment(lua_State *L)
lua_getglobal(L, "_G");
return 1;
}
- lua_getfield(L, LUA_REGISTRYINDEX, SCRIPT_MOD_NAME_FIELD);
+ lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_CURRENT_MOD_NAME);
if (!lua_isstring(L, -1)) {
lua_pushnil(L);
return 1;
@@ -383,7 +383,7 @@ int ModApiUtil::l_request_insecure_environment(lua_State *L)
lua_pushnil(L);
return 1;
}
- lua_getfield(L, LUA_REGISTRYINDEX, "globals_backup");
+ lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_GLOBALS_BACKUP);
return 1;
}