From 33e32e436894263468082310ff518015876a567f Mon Sep 17 00:00:00 2001 From: shagu Date: Mon, 25 Feb 2019 19:29:25 +0100 Subject: [PATCH] player: prevent energytick events when possible --- modules/player.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/player.lua b/modules/player.lua index e8bf6b6f..c2b9a025 100644 --- a/modules/player.lua +++ b/modules/player.lua @@ -34,13 +34,21 @@ pfUI:RegisterModule("player", function () pfUI.uf.player.power.tick:RegisterEvent("PLAYER_ENTERING_WORLD") pfUI.uf.player.power.tick:RegisterEvent("UNIT_DISPLAYPOWER") + pfUI.uf.player.power.tick:SetScript("OnShow", function() + this.spark:Show() + end) + + pfUI.uf.player.power.tick:SetScript("OnHide", function() + this.spark:Hide() + end) + pfUI.uf.player.power.tick:SetScript("OnEvent", function() if event == "PLAYER_ENTERING_WORLD" then this.lastTick = GetTime() end if event == "PLAYER_ENTERING_WORLD" or ( event == "UNIT_DISPLAYPOWER" and arg1 == "player" ) then if UnitPowerType("player") ~= 3 then - this.spark:Hide() + this:Hide() else - this.spark:Show() + this:Show() end end end) @@ -64,6 +72,7 @@ pfUI:RegisterModule("player", function () end pfUI.uf.player.power.tick:SetScript("OnUpdate", function() + if UnitPowerType("player") ~= 3 then this:Hide() end if not this.energy then this.energy = UnitMana("player") end if(UnitMana("player") > this.energy or GetTime() >= this.lastTick + 2) then