diff --git a/GlobalMethods.h b/GlobalMethods.h index 5af4baf..8ac9702 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -51,6 +51,24 @@ namespace LuaGlobalFunctions return 1; } + /** + * Returns emulator .conf RealmID + * + * - for MaNGOS returns the realmID as it is stored in the core. + * - for TrinityCore returns the realmID as it is in the conf file. + * @return uint32 realm ID + */ + + int GetRealmID(lua_State* L) + { +#ifdef MANGOS + Eluna::Push(L, eWorld->GetRealmID()); +#else + Eluna::Push(L, sConfigMgr->GetIntDefault("RealmID", 1)); +#endif + return 1; + } + /** * Returns emulator version * diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index db06749..ed640f8 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -77,6 +77,7 @@ luaL_Reg GlobalMethods[] = // Getters { "GetLuaEngine", &LuaGlobalFunctions::GetLuaEngine }, { "GetCoreName", &LuaGlobalFunctions::GetCoreName }, + { "GetRealmID", &LuaGlobalFunctions::GetRealmID }, { "GetCoreVersion", &LuaGlobalFunctions::GetCoreVersion }, { "GetCoreExpansion", &LuaGlobalFunctions::GetCoreExpansion }, { "GetQuest", &LuaGlobalFunctions::GetQuest },