From df4e0ed67d10fb4b84e144644fa509a966f8c047 Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 3 Mar 2020 17:36:08 +0100 Subject: [PATCH] hunterbar: delay and queue ability scanner events --- modules/hunterbar.lua | 48 +++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/modules/hunterbar.lua b/modules/hunterbar.lua index 1667f521..af9b99ae 100644 --- a/modules/hunterbar.lua +++ b/modules/hunterbar.lua @@ -12,29 +12,41 @@ pfUI:RegisterModule("hunterbar", "vanilla", function () pfUI.hunterbar:RegisterEvent("ACTIONBAR_SLOT_CHANGED") pfUI.hunterbar:RegisterEvent("PLAYER_ENTERING_WORLD") pfUI.hunterbar:SetScript("OnEvent", function() - pfUI.hunterbar.melee = nil - pfUI.hunterbar.ranged = nil - - for i=1,120 do - if pfUI.hunterbar.melee and pfUI.hunterbar.ranged then return end - - scanner:SetAction(i) - - local left = scanner:Line(1) - if left then - if left == L["hunterpaging"]["MELEE"] then - pfUI.hunterbar.melee = i - elseif left == L["hunterpaging"]["RANGED"] then - pfUI.hunterbar.ranged = i - end - end + if event == "PLAYER_ENTERING_WORLD" then + this.event = GetTime() + 3 + elseif this.event and this.event < GetTime() + .2 then + this.event = GetTime() + .1 end end) pfUI.hunterbar:SetScript("OnUpdate", function() - if not pfUI.hunterbar.melee or not pfUI.hunterbar.ranged then return end + -- we got an event 0.1s ago, scanning for new Skills + if this.event and this.event <= GetTime() then + this.event = nil + this.melee = nil + this.ranged = nil - if IsActionInRange(pfUI.hunterbar.melee) == 1 and IsActionInRange(pfUI.hunterbar.ranged) == 0 then + for i=1,120 do + if this.melee and this.ranged then return end + + scanner:SetAction(i) + + local left = scanner:Line(1) + if left then + if left == L["hunterpaging"]["MELEE"] then + this.melee = i + elseif left == L["hunterpaging"]["RANGED"] then + this.ranged = i + end + end + end + end + + -- skip further code when no abilities were found + if not this.melee or not this.ranged then return end + + -- do the actual rangedetection and barswapping + if IsActionInRange(this.melee) == 1 and IsActionInRange(this.ranged) == 0 then if _G.CURRENT_ACTIONBAR_PAGE == 1 then _G.CURRENT_ACTIONBAR_PAGE = 9 ChangeActionBarPage()