From 4b6ed04926878b89037cf61994be256d378f07d3 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 20 Mar 2026 15:44:25 -0700 Subject: [PATCH] feat: add GetZoneText, GetSubZoneText, and GetMinimapZoneText Lua APIs Add zone name query functions using worldStateZoneId + getAreaName lookup. GetRealZoneText is aliased to GetZoneText. These are heavily used by boss mod addons (DBM) for zone detection and by quest tracking addons. --- src/addons/lua_engine.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index 8686ef3c..1e676fad 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -641,6 +641,29 @@ static int lua_GetCurrentMapAreaID(lua_State* L) { return 1; } +// GetZoneText() / GetRealZoneText() → current zone name +static int lua_GetZoneText(lua_State* L) { + auto* gh = getGameHandler(L); + if (!gh) { lua_pushstring(L, ""); return 1; } + uint32_t zoneId = gh->getWorldStateZoneId(); + if (zoneId != 0) { + std::string name = gh->getWhoAreaName(zoneId); + if (!name.empty()) { lua_pushstring(L, name.c_str()); return 1; } + } + lua_pushstring(L, ""); + return 1; +} + +// GetSubZoneText() → subzone name (same as zone for now — server doesn't always send subzone) +static int lua_GetSubZoneText(lua_State* L) { + return lua_GetZoneText(L); // Best-effort: zone and subzone often overlap +} + +// GetMinimapZoneText() → zone name displayed near minimap +static int lua_GetMinimapZoneText(lua_State* L) { + return lua_GetZoneText(L); +} + // --- Player State API --- // These replace the hardcoded "return false" Lua stubs with real game state. @@ -1183,6 +1206,10 @@ void LuaEngine::registerCoreAPI() { {"GetLocale", lua_GetLocale}, {"GetBuildInfo", lua_GetBuildInfo}, {"GetCurrentMapAreaID", lua_GetCurrentMapAreaID}, + {"GetZoneText", lua_GetZoneText}, + {"GetRealZoneText", lua_GetZoneText}, + {"GetSubZoneText", lua_GetSubZoneText}, + {"GetMinimapZoneText", lua_GetMinimapZoneText}, // Player state (replaces hardcoded stubs) {"IsMounted", lua_IsMounted}, {"IsFlying", lua_IsFlying},