From 9cd2cfa46e1e0638da05a4a3c6a4a78ed5edf107 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Mon, 23 Mar 2026 02:47:30 -0700 Subject: [PATCH] feat: add title API (GetCurrentTitle, GetTitleName, SetCurrentTitle) GetCurrentTitle() returns the player's chosen title bit index. GetTitleName(bit) returns the formatted title string from CharTitles.dbc (e.g., "Commander %s", "%s the Explorer"). SetCurrentTitle() is a stub for title switching. Used by title display addons and the character panel title selector. --- 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 ac971cad..ab41c206 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -5182,6 +5182,25 @@ void LuaEngine::registerCoreAPI() { if (gh) gh->requestPvpLog(); return 0; }}, + // --- Titles --- + {"GetCurrentTitle", [](lua_State* L) -> int { + auto* gh = getGameHandler(L); + lua_pushnumber(L, gh ? gh->getChosenTitleBit() : -1); + return 1; + }}, + {"GetTitleName", [](lua_State* L) -> int { + auto* gh = getGameHandler(L); + int bit = static_cast(luaL_checknumber(L, 1)); + if (!gh || bit < 0) { lua_pushnil(L); return 1; } + std::string title = gh->getFormattedTitle(static_cast(bit)); + if (title.empty()) { lua_pushnil(L); return 1; } + lua_pushstring(L, title.c_str()); + return 1; + }}, + {"SetCurrentTitle", [](lua_State* L) -> int { + (void)L; // Title changes require CMSG_SET_TITLE which we don't expose yet + return 0; + }}, // --- Inspect --- {"GetInspectSpecialization", [](lua_State* L) -> int { auto* gh = getGameHandler(L);