Thread Tools Display Modes
07-06-10, 07:21 AM   #1
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
SetCooldown Weirdness

Why is it, that for some reason, the cooldown on my button only flashes and then disappears? I'm trying to get a little windfury cooldown timer on my screen.

Code: http://wowi.pastey.net/138340
  Reply With Quote
07-06-10, 07:43 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,951
Could it be the global cooldown being picked up instead of the actual cooldown ?

I'm also not seeing the cooldown information being retrieved, but there may be another way that I wasn't aware of. This is how I get the cooldown in my mage ports addon.

Code:
local function ActivateCooldown(self)
  local SpellName, _, SpellIcon = GetSpellInfo(spellID);
  local CooldownStart, CooldownDuration, CooldownEnabled = GetSpellCooldown(SpellName);
  if ( CooldownEnabled ) then
    if ( CooldownDuration > 0 ) then 
      self.Text:Show();
      self:Show();
    end
  end
end
Code:
-- Deactivate the Cooldown for this button by hiding the frame
local function DeActivateCooldown(self)
  self.Text:Hide();
  self:Hide();
end
Code:
local function UpdateCooldown(self)
  local TimeNow = GetTime();
  local SpellName, _, SpellIcon = GetSpellInfo(spellID);
  local CooldownStart, CooldownDuration, CooldownEnabled = GetSpellCooldown(SpellName);
  if ( not CooldownEnabled ) then DeActivateCooldown(self); return; end
  if ( CooldownDuration == 0 ) then DeActivateCooldown(self); return; end	
  local DiffTime = TimeNow - CooldownStart;
  local CooldownCounter = CooldownDuration - DiffTime;
  CooldownCounter = math.floor(CooldownCounter);
  if ( CooldownCounter > 0 ) then	
    self.Text:SetText(CooldownCounter);	
  else
    DeActivateCooldown(self);
  end
end
Code:
local Button = CreateFrame("Button", ButtonName, UIParent,"ActionButtonTemplate,SecureActionButtonTemplate");	
----etc	
Button.Cooldown = CreateFrame("Frame", ButtonName.."_Cooldown", Button);
Button.Cooldown:SetAllPoints(Button);
Button.Cooldown.Text = Button.Cooldown:CreateFontString(ButtonName.."_Cooldown_Text", 'ARTWORK', "GameFontNormal");
Button.Cooldown:SetScript("OnUpdate",UpdateCooldown);
Button.Cooldown:SetScript("OnEvent",ActivateCooldown);
Button.Cooldown:RegisterEvent("SPELL_UPDATE_COOLDOWN");
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
07-06-10, 08:27 AM   #3
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Windfury has an internal cooldown of 3 seconds, if you look at the code I determine the starttime (time minus lag), and set the cooldown to 3 seconds.

I know I can make my own fontstring, but I want the cooldown animation on my button

Last edited by ravagernl : 07-06-10 at 08:29 AM.
  Reply With Quote
07-06-10, 09:44 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,951
Ah the cycle animation I prefer the number but its a personal preference. And I see you are using the combat log to monitor the spell usage rather than track the cooldown event, so not sure what the difference is there, if there is any.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
07-07-10, 07:02 AM   #5
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
I don't believe Windfury has a cooldown event, hence the "hidden cooldown". The cooldown of 3 seconds starts whenever "Windfury Attack" hits, crits, or misses (also when it is dodged etc.).

The problem is not that I can't detect when the cooldown starts, the problem is that the animation doesn't seem to start.

Last edited by ravagernl : 07-07-10 at 07:04 AM.
  Reply With Quote
07-07-10, 07:50 AM   #6
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Try GetTime() instead of time() for the starting time
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.
  Reply With Quote
07-07-10, 03:48 PM   #7
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Yup, somebody at wowace also told me that That works. But thanks
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » SetCooldown Weirdness


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off