From 3a4d59d584e4ea105735c9f7d30add5098181336 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 20 Mar 2026 18:53:56 -0700 Subject: [PATCH] feat: add GetXPExhaustion and GetRestState Lua APIs for rested XP tracking GetXPExhaustion() returns rested XP pool remaining (nil if none). GetRestState() returns 1 (normal) or 2 (rested) based on inn/city state. Used by XP bar addons like Titan Panel and XP tracking WeakAuras. --- src/addons/lua_engine.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index 157dd509..f9821783 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -1003,6 +1003,23 @@ static int lua_UnitXPMax(lua_State* L) { return 1; } +// GetXPExhaustion() → rested XP pool remaining (nil if none) +static int lua_GetXPExhaustion(lua_State* L) { + auto* gh = getGameHandler(L); + if (!gh) { lua_pushnil(L); return 1; } + uint32_t rested = gh->getPlayerRestedXp(); + if (rested > 0) lua_pushnumber(L, rested); + else lua_pushnil(L); + return 1; +} + +// GetRestState() → 1 = normal, 2 = rested +static int lua_GetRestState(lua_State* L) { + auto* gh = getGameHandler(L); + lua_pushnumber(L, (gh && gh->isPlayerResting()) ? 2 : 1); + return 1; +} + // --- Quest Log API --- static int lua_GetNumQuestLogEntries(lua_State* L) { @@ -1675,6 +1692,8 @@ void LuaEngine::registerCoreAPI() { {"GetServerTime", lua_GetServerTime}, {"UnitXP", lua_UnitXP}, {"UnitXPMax", lua_UnitXPMax}, + {"GetXPExhaustion", lua_GetXPExhaustion}, + {"GetRestState", lua_GetRestState}, // Quest log API {"GetNumQuestLogEntries", lua_GetNumQuestLogEntries}, {"GetQuestLogTitle", lua_GetQuestLogTitle},