From d7d68198554ed6798dae65471d1455e7dd9ecb72 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 20 Mar 2026 16:42:06 -0700 Subject: [PATCH] feat: add generic UnitAura(unit, index, filter) Lua API function Add UnitAura() that accepts WoW-compatible filter strings: "HELPFUL" for buffs, "HARMFUL" for debuffs. Delegates to existing UnitBuff/UnitDebuff logic. Many addons (WeakAuras, Grid, etc.) use UnitAura with filter strings rather than separate UnitBuff/UnitDebuff calls. --- src/addons/lua_engine.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index 76149dfd..99872925 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -396,6 +396,17 @@ static int lua_UnitAura(lua_State* L, bool wantBuff) { static int lua_UnitBuff(lua_State* L) { return lua_UnitAura(L, true); } static int lua_UnitDebuff(lua_State* L) { return lua_UnitAura(L, false); } +// UnitAura(unit, index, filter) — generic aura query with filter string +// filter: "HELPFUL" = buffs, "HARMFUL" = debuffs, "PLAYER" = cast by player, +// "HELPFUL|PLAYER" = buffs cast by player, etc. +static int lua_UnitAuraGeneric(lua_State* L) { + const char* filter = luaL_optstring(L, 3, "HELPFUL"); + std::string f(filter ? filter : "HELPFUL"); + for (char& c : f) c = static_cast(std::toupper(static_cast(c))); + bool wantBuff = (f.find("HARMFUL") == std::string::npos); + return lua_UnitAura(L, wantBuff); +} + // --- Action API --- static int lua_SendChatMessage(lua_State* L) { @@ -1189,6 +1200,7 @@ void LuaEngine::registerCoreAPI() { {"InCombatLockdown", lua_InCombatLockdown}, {"UnitBuff", lua_UnitBuff}, {"UnitDebuff", lua_UnitDebuff}, + {"UnitAura", lua_UnitAuraGeneric}, {"GetNumAddOns", lua_GetNumAddOns}, {"GetAddOnInfo", lua_GetAddOnInfo}, {"GetSpellInfo", lua_GetSpellInfo},