X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fscript%2Flua_api%2Fl_base.cpp;h=dfe743b72cbb1510f40ff14dff3f3eef46bfcf44;hb=f7088f69ab7406ea9fefa853fa7ce11f914e88cf;hp=136fcc5070a3a349ba9d4d0d6a3c6d9f5ad9012d;hpb=0df736173e60df06a7a7162c285b9c5731a07c20;p=dragonfireclient.git diff --git a/src/script/lua_api/l_base.cpp b/src/script/lua_api/l_base.cpp index 136fcc507..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,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 ".";