NeedToKnow

NeedToKnow

2M Downloads

v4.7.4 cooldown error

Closed this issue ยท 5 comments

commented

Unfortunately, there's a new-and-different error that slipped though to the 4.7.4 package. On login, this begins spamming:

273x NeedToKnow/Cooldown.lua:31: bad argument #1 to 'GetSpellCooldown' (Usage: local spellCooldownInfo = C_Spell.GetSpellCooldown(spellIdentifier))
[string "=[C]"]: in function `GetSpellCooldown'
[string "@NeedToKnow/Cooldown.lua"]:31: in function <NeedToKnow/Cooldown.lua:30>
[string "@NeedToKnow/Cooldown.lua"]:95: in function `GetCooldown'
[string "@NeedToKnow/BarEngine.lua"]:623: in function `GetTrackedInfo'
[string "@NeedToKnow/BarEngine.lua"]:465: in function `CheckAura'
[string "@NeedToKnow/BarEngine.lua"]:58: in function `Update'
[string "@NeedToKnow/BarGroup.lua"]:93: in function `Update'
[string "@NeedToKnow/BarGroup.lua"]:31: in function `UpdateBarGroups'
[string "@NeedToKnow/NeedToKnow.lua"]:53: in function `Update'
[string "@NeedToKnow/Profile.lua"]:255: in function `ActivateProfile'
[string "@NeedToKnow/Profile.lua"]:274: in function `UpdateActiveProfile'
[string "@NeedToKnow/ExecutiveFrame.lua"]:67: in function `f'
[string "@NeedToKnow/ExecutiveFrame.lua"]:25: in function <NeedToKnow/ExecutiveFrame.lua:22>

Locals:
(*temporary) = <table> {
 castTime = 0
 name = "Lay on Hands"
 minRange = 0
 originalIconID = 135928
 iconID = 135928
 maxRange = 40
 spellID = 633
}
commented

I've had some good results with the cooldown errors with this, but it needs more testing:

--- NeedToKnow/Cooldown.lua.orig	2024-08-15 20:51:39.120547400 -0400
+++ NeedToKnow/Cooldown.lua	2024-08-15 20:51:51.355324400 -0400
@@ -16,18 +16,21 @@
 
 -- Functions that are different between Retail and Classic as of patch 11.0.0
 local function GetMySpellInfo(spell)
+	if type(spell) == "table" then spell = spell.spellID end
 	local info = C_Spell.GetSpellInfo(spell)  -- Only in Retail
 	if info then
 		return info.name, nil, info.iconID, info.castTime, info.minRange, info.maxRange, info.spellID, info.originalIconID
 	end
 end
 local function GetMySpellCharges(spell)
+	if type(spell) == "table" then spell = spell.spellID end
 	local info = C_Spell.GetSpellCharges(spell)  -- Only in Retail
 	if info then
 		return info.currentCharges, info.maxCharges, info.cooldownStartTime, info.cooldownDuration, info.chargeModRate
 	end
 end
 local function GetMySpellCooldown(spell)
+	if type(spell) == "table" then spell = spell.spellID end
 	local info = C_Spell.GetSpellCooldown(spell)  -- Only in Retail
 	if info then
 		return info.startTime, info.duration, info.isEnabled, info.modRate

and, weirdly, this has been needed also:

--- NeedToKnow/BarText.lua.orig	2024-08-15 20:54:24.988723400 -0400
+++ NeedToKnow/BarText.lua	2024-08-15 20:58:19.738826200 -0400
@@ -47,6 +47,8 @@
 	else
 		name = ""
 	end
+	-- sometimes shownName/buffName is coming though as a table:
+	if type(name) == 'table' then name = name.name end 
 
 	local count = self.count
 	if settings.show_count and count and count > 1 then
commented

Oh wierd. That "Locals:" in the first error is the output of C_Spell.GetSpellInfo(), but it's getting sent to GetSpellCooldown() as a name/ID. I think maybe patch 11.0.2 didn't remove GetSpellInfo() but instead assigned it to C_Spell.GetSpellInfo() (whose output is structured differently). So the line
name, _, icon, _, _, _, spellID = GetSpellInfo(spell)
is assigning that table to name and then info.name.

Lemme see if I can't clean this up.

commented

Okay, try this latest version on GitHub to see if that fixes it.

commented

Marking this fixed based on feedback from CurseForge users

commented

Grabbed the latest just now and it's working great. Thank you!