]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/script/lua_api/l_base.cpp
Clang-format: fix some header files and remove them from whitelist
[dragonfireclient.git] / src / script / lua_api / l_base.cpp
index 136fcc5070a3a349ba9d4d0d6a3c6d9f5ad9012d..dfe743b72cbb1510f40ff14dff3f3eef46bfcf44 100644 (file)
@@ -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;
@@ -37,6 +37,18 @@ Server *ModApiBase::getServer(lua_State *L)
        return getScriptApiBase(L)->getServer();
 }
 
+#ifndef SERVER
+Client *ModApiBase::getClient(lua_State *L)
+{
+       return getScriptApiBase(L)->getClient();
+}
+#endif
+
+IGameDef *ModApiBase::getGameDef(lua_State *L)
+{
+       return getScriptApiBase(L)->getGameDef();
+}
+
 Environment *ModApiBase::getEnv(lua_State *L)
 {
        return getScriptApiBase(L)->getEnv();
@@ -49,12 +61,12 @@ GUIEngine *ModApiBase::getGuiEngine(lua_State *L)
 
 std::string ModApiBase::getCurrentModPath(lua_State *L)
 {
-       lua_getfield(L, LUA_REGISTRYINDEX, "current_modname");
-       const char *current_modname = lua_tostring(L, -1);
-       if (!current_modname)
+       lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_CURRENT_MOD_NAME);
+       const char *current_mod_name = lua_tostring(L, -1);
+       if (!current_mod_name)
                return ".";
 
-       const ModSpec *mod = getServer(L)->getModSpec(current_modname);
+       const ModSpec *mod = getServer(L)->getModSpec(current_mod_name);
        if (!mod)
                return ".";