From 28689c4b37a1358d08ee62d7bb31ca991e3610a1 Mon Sep 17 00:00:00 2001 From: Bunny67 Date: Tue, 25 Aug 2020 19:27:05 +0300 Subject: [PATCH] add "Queued Action" trigger --- WeakAuras/Prototypes.lua | 66 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 787eb82..b130ca6 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -2,9 +2,10 @@ if not WeakAuras.IsCorrectVersion() then return end -- Lua APIs local tinsert, tsort = table.insert, table.sort -local tostring = tostring +local tonumber, tostring = tonumber, tostring local select, pairs, type = select, pairs, type local ceil, min = ceil, min +local match = string.match -- WoW APIs local GetTalentInfo = GetTalentInfo @@ -13,6 +14,7 @@ local GetSpellInfo, GetItemInfo, GetItemCount, GetItemIcon = GetSpellInfo, GetIt local GetShapeshiftFormInfo, GetShapeshiftForm = GetShapeshiftFormInfo, GetShapeshiftForm local GetRuneCooldown, UnitCastingInfo, UnitChannelInfo = GetRuneCooldown, UnitCastingInfo, UnitChannelInfo local UnitDetailedThreatSituation, UnitThreatSituation = UnitDetailedThreatSituation, UnitThreatSituation +local GetActionInfo, GetMacroSpell, GetSpellLink = GetActionInfo, GetMacroSpell, GetSpellLink local WeakAuras = WeakAuras local L = WeakAuras.L @@ -650,6 +652,26 @@ function WeakAuras.IsSpellKnownIncludingPet(spell) end end +function WeakAuras.FindSpellActionButtons(spellID) + for i = 120, 1, -1 do + local actionType, id, _, globalID = GetActionInfo(i) + if actionType == "spell" and globalID and globalID == spellID then + return i + elseif actionType == "macro" then + local name, rank = GetMacroSpell(id) + if name then + local spellLink = GetSpellLink(name, rank or "") + if spellLink then + globalID = tonumber(match(spellLink, "spell:(%d+)")) + if globalID and globalID == spellID then + return i + end + end + end + end + end +end + local function valuesForTalentFunction(trigger) return function() local single_class; @@ -5573,6 +5595,48 @@ WeakAuras.event_prototypes = { automaticrequired = true }, + ["Queued Action"] = { + type = "status", + events = { + ["events"] = {"ACTIONBAR_UPDATE_STATE"} + }, + internal_events = { + "ACTIONBAR_SLOT_CHANGED", + "ACTIONBAR_PAGE_CHANGED" + }, + name = L["Queued Action"], + init = function(trigger) + trigger.spellName = trigger.spellName or 0 + local ret = [=[ + local spellid = tonumber(%q) + local button + if spellid then + button = WeakAuras.FindSpellActionButtons(spellid) + end + ]=] + return ret:format(trigger.spellName) + end, + args = { + { + name = "spellName", + required = true, + display = L["Spell"], + type = "spell", + test = "true", + forceExactOption = true, + }, + { + hidden = true, + test = "button and IsCurrentAction(button)"; + }, + }, + iconFunc = function(trigger) + local _, _, icon = GetSpellInfo(trigger.spellName or 0); + return icon; + end, + automaticrequired = true + }, + ["Range Check"] = { type = "status", events = {