WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   ICD Tracking script (https://www.wowinterface.com/forums/showthread.php?t=51886)

wallst 02-10-15 09:46 PM

ICD Tracking script
 
Hi, help modify this script. Need hide icon frame when cd timer expired
Lua Code:
  1. local t=CreateFrame("FRAME")
  2. t:SetPoint("RIGHT",TargetFrame,12,12)
  3. t:SetSize(30,30)
  4. t.c=CreateFrame("Cooldown","cd1")
  5. t.c:SetAllPoints(t)
  6. t.t=t:CreateTexture(nil,"BORDER")
  7. t.t:SetAllPoints()
  8. t.t:SetTexture("Interface\\Icons\\spell_holy_divinepurpose")
  9. t:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  10. t:Hide()
  11.  
  12. t:SetScript("OnEvent", function(...)
  13. local b,_,_,e,_,_,_,_,_,_,l = select(4, ...)
  14. if (e == UnitName("Player") and (b=="SPELL_AURA_REMOVED")and l==126705)
  15. then t:Show() CooldownFrame_SetTimer(cd1,GetTime(),45,1)
  16. return
  17. end
  18. end)

sticklord 02-11-15 09:51 PM

Try this:
Lua Code:
  1. local t=CreateFrame("FRAME")
  2. t:SetPoint("RIGHT",TargetFrame,12,12)
  3. t:SetSize(30,30)
  4. t.c=CreateFrame("Cooldown","cd1")
  5. t.c:SetAllPoints(t)
  6. t.t=t:CreateTexture(nil,"BORDER")
  7. t.t:SetAllPoints()
  8. t.t:SetTexture("Interface\\Icons\\spell_holy_divinepurpose")
  9. t:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  10. t:Hide()
  11.  
  12. t:SetScript("OnEvent", function(...)
  13. local b,_,_,e,_,_,_,_,_,_,l = select(4, ...)
  14. if (e == UnitName("Player") and (b=="SPELL_AURA_REMOVED")and l==126705)
  15. then t:Show() CooldownFrame_SetTimer(cd1,GetTime(),45,1)
  16. C_Timer.After(45, function() t:Hide() end)
  17. return
  18. end
  19. end)

wallst 02-12-15 02:16 PM

sticklord thanks!

wallst 02-26-15 10:12 AM

This script don't work after 6.1 patch. What happened ?

Seerah 02-26-15 05:14 PM

What, exactly, "doesn't work"?

wallst 02-27-15 05:22 PM

Quote:

Originally Posted by Seerah (Post 307005)
What, exactly, "doesn't work"?

Lua Code:
  1. then t:Show() CooldownFrame_SetTimer(cd1,GetTime(),45,1)
  2. C_Timer.After(45, function() t:Hide() end)

Phanx 02-27-15 10:42 PM

It doesn't work because your cooldown frame is (a) not parented to your frame and (b) not inheriting from the correct (or any) template. Your code is also really badly formatted; addons aren't macros, and space isn't limited, so you should really use good spacing, proper indentation, and meaningful variable names:

Code:

local t = CreateFrame("Frame")
t:SetPoint("RIGHT", TargetFrame, 12, 12)
t:SetSize(30, 30)

t.cd = CreateFrame("Cooldown", nil, t, "CooldownFrameTemplate")
t.cd:SetAllPoints(true)

t.icon = t:CreateTexture(nil, "ARTWORK")
t.icon:SetAllPoints(true)
t.icon:SetTexture("Interface\\Icons\\spell_holy_divinepurpose")

t:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
t:Hide()

local PLAYER_NAME = UnitName("player")
local function Hide() t:Hide() end

t:SetScript("OnEvent", function(self, event, _, combatEvent, _, _, sourceName, _, _, _, _, _, _, spellID)
        if sourceName == PLAYER_NAME and combatEvent == "SPELL_AURA_REMOVED" and spellID == 126705 then
                self:Show()
                CooldownFrame_SetTimer(self.cd, GetTime(), 45, 1)
                C_Timer.After(45, Hide)
        end
end)


wallst 02-28-15 09:38 AM

Phanx, your code doesn't work too.

Phanx 02-28-15 11:36 PM

If you want any more help you're going to have to be more specific than "doesn't work". Where are you putting the code? How do you know it's being loaded? Does it raise any error messages? If so, what are they? If not, do you have any kind of error display enabled? What exactly are you doing, and what do you think the addon should be doing in response to that? What is it doing instead?


All times are GMT -6. The time now is 09:51 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI