Thread Tools Display Modes
08-10-24, 09:57 PM   #1
Macker2k
A Defias Bandit
Join Date: Aug 2024
Posts: 2
Creating Cooldown Frame

Hi,

I am not even sure how to describe it, but I am getting an error on the highlighted line.

Error: 'SetCooldown' (must be a finite number - Usage: self:SetCooldown(start, duration [, modRate]))
[string "=[C]"]: in function `SetCooldown'




Code:
local cd = CreateFrame("Cooldown", "ConROWindowCooldown", frame, "CooldownFrameTemplate")
		cd:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START");
		cd:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE");
		cd:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP");
		cd:RegisterEvent("UNIT_SPELLCAST_SENT");
		cd:RegisterEvent("UNIT_SPELLCAST_START");
		cd:RegisterEvent("UNIT_SPELLCAST_DELAYED");
		cd:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED");
                cd:RegisterEvent("UNIT_SPELLCAST_FAILED");
		cd:RegisterEvent("UNIT_SPELLCAST_START");
		cd:RegisterEvent("UNIT_SPELLCAST_STOP");

		cd:SetAllPoints(frame);
		cd:SetFrameStrata('MEDIUM');
		cd:SetFrameLevel('54');
		if ConRO.db.profile.enableWindowCooldown then
			cd:SetScript("OnEvent",function(self)
				local gcdStart, gcdDuration = C_Spell.GetSpellCooldown(61304)
				local _, _, _, startTimeMS, endTimeMS = UnitCastingInfo('player');
				local _, _, _, startTimeMSchan, endTimeMSchan = UnitChannelInfo('player');
				if not (endTimeMS or endTimeMSchan) then
					cd:SetCooldown(gcdStart, gcdDuration)
				elseif endTimeMSchan then
					local chanStart  = startTimeMSchan / 1000;
					local chanDuration = endTimeMSchan/1000 - GetTime();
					cd:SetCooldown(chanStart, chanDuration)
				else
					local spStart  = startTimeMS / 1000;
					local spDuration = endTimeMS/1000 - GetTime();
					cd:SetCooldown(spStart, spDuration)
				end

Last edited by Macker2k : 08-10-24 at 10:01 PM.
  Reply With Quote
08-10-24, 10:33 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,975
Unlike the old GetSpellCooldown, the new C_Spell.GetSpellCooldown returns a table (or nil). You will need to take the information from the returned table (if it's not nil) and initalise gcdStart and gcdDuration
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-12-24, 12:06 AM   #3
Macker2k
A Defias Bandit
Join Date: Aug 2024
Posts: 2
Originally Posted by Fizzlemizz View Post
Unlike the old GetSpellCooldown, the new C_Spell.GetSpellCooldown returns a table (or nil). You will need to take the information from the returned table (if it's not nil) and initalise gcdStart and gcdDuration
Thank you Fizzle!!!

If you dont mind, another issue I am having is with this code.

Error:
Code:
ConRO/core.lua:2455: attempt to call global 'GetSpellInfo' (a nil value)

Code:
function ConRO:InvokeNextSpell()
	local oldSkill = self.Spell;

	local timeShift, currentSpell, gcd = ConRO:EndCast();
	local iterate = self:NextSpell(timeShift, currentSpell, gcd, self.PlayerTalents, self.PvPTalents);
	self.Spell = self.SuggestedSpells[1];

	ConRO:GetTimeToDie();
--	ConRO:UpdateRotation();
--	ConRO:UpdateButtonGlow();
	local spellName, _, spellTexture = GetSpellInfo(self.Spell);
	local _, _, spellTexture2 = GetSpellInfo(self.SuggestedSpells[2]);
	local _, _, spellTexture3 = GetSpellInfo(self.SuggestedSpells[3]);

	if (oldSkill ~= self.Spell or oldSkill == nil) and self.Spell ~= nil then
		self:GlowNextSpell(self.Spell);
		ConROWindow.fontkey:SetText(ConRO:improvedGetBindingText(ConRO:FindKeybinding(self.Spell)));
		ConROWindow2.fontkey:SetText(ConRO:improvedGetBindingText(ConRO:FindKeybinding(self.SuggestedSpells[2])));
		ConROWindow3.fontkey:SetText(ConRO:improvedGetBindingText(ConRO:FindKeybinding(self.SuggestedSpells[3])));
		if spellName ~= nil then
			ConROWindow.texture:SetTexture(spellTexture);
			ConROWindow.font:SetText(spellName);
			ConROWindow2.texture:SetTexture(spellTexture2);
			ConROWindow3.texture:SetTexture(spellTexture3);
		else
			local itemName, _, _, _, _, _, _, _, _, itemTexture = GetItemInfo(self.Spell);
			local _, _, _, _, _, _, _, _, _, itemTexture2 = GetItemInfo(self.SuggestedSpells[2]);
			local _, _, _, _, _, _, _, _, _, itemTexture3 = GetItemInfo(self.SuggestedSpells[3]);
			ConROWindow.texture:SetTexture(itemTexture);
			ConROWindow.font:SetText(itemName);
			ConROWindow2.texture:SetTexture(itemTexture2);
			ConROWindow3.texture:SetTexture(itemTexture3);
		end
	end

	if self.Spell == nil and oldSkill ~= nil then
		self:GlowClear();
		ConROWindow.texture:SetTexture('Interface\\AddOns\\ConRO\\images\\Bigskull');
		ConROWindow.font:SetText(" ");
		ConROWindow.fontkey:SetText(" ");
		ConROWindow2.texture:SetTexture('Interface\\AddOns\\ConRO\\images\\Bigskull');
		ConROWindow2.fontkey:SetText(" ");
		ConROWindow3.texture:SetTexture('Interface\\AddOns\\ConRO\\images\\Bigskull');
		ConROWindow3.fontkey:SetText(" ");
	end
end
  Reply With Quote
08-12-24, 03:41 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 6,009
The Spellbook has hand changes and many other functions have been given their own namespace now.

The bottom of this page details what functions have been removed and added

https://warcraft.wiki.gg/wiki/Patch_11.0.0/API_changes

GetSpell is amongst them with this being the page set up for it
https://warcraft.wiki.gg/wiki/API_C_Spell.GetSpellInfo
__________________


All Level 70 Characters:
Demon Warlock
Resto Druid
Disc Priest
Resto Shaman
Survival Hunter
Augment Evoker
Frost Mage
Vengence Demon Hunter
Rogue ( was subtlety )

Brewmaster Monk (TR)
Prot Paladin (TR)
Blood Death Knight ( TR)

As you can see I am missing a warrior

And .. I don't have all the allied races covered. Time Runner time when it happens again

  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Creating Cooldown Frame

Thread Tools
Display Modes

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