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;
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();
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 ".";