X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fscript%2Flua_api%2Fl_base.cpp;h=dfe743b72cbb1510f40ff14dff3f3eef46bfcf44;hb=f7088f69ab7406ea9fefa853fa7ce11f914e88cf;hp=6ad3e4ba22d9183c1c63d5133cbcf4b1a5b60f88;hpb=c00b6812b116c7e08eaf00c52504aa7b93a936a1;p=dragonfireclient.git diff --git a/src/script/lua_api/l_base.cpp b/src/script/lua_api/l_base.cpp index 6ad3e4ba2..dfe743b72 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; @@ -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,7 +61,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 ".";