DFortun81 / ATT-WRATH-Classic

Addon for Tracking Collections & Account Completion in World of Warcraft: Wrath of the Lich King Classic
Other
2 stars 1 forks source link

Attempt to compare number with string error for the past few versions #10

Closed bloodstrike closed 2 years ago

bloodstrike commented 2 years ago

1x ATT-Classic\ATT-Classic-1.0.9.lua:8685: attempt to compare number with string [string "@ATT-Classic\ATT-Classic-1.0.9.lua"]:8685: in function `GetSpellName'

I've tracked this down to, I think, some spell having its rank stored as a string instead of a number.

The line that bug sack points to is: if (rawget(MaxSpellRankPerSpellName, spellName) or 0) < rank then

If I change that to: if (rawget(MaxSpellRankPerSpellName, spellName) or 0) < tonumber(rank) then

the error stops occurring.

DFortun81 commented 2 years ago

Add this code to the "if rank then" body if type(rank) ~= "number" then print("Spell ID #" .. spellID .. " (Rank " .. rank .. ") " .. type(rank) .. " be causing issues, mon!"); end And let me know which spellID is causing this problem for you. (Rank should never ever be a string)

bloodstrike commented 2 years ago

Ok false alarm. Added that code to the body of that if statement and started getting all kinds of spells with string ranks, which made no sense. I don't know why I didn't think of this before, but the only add-on that I was running that even referenced rank was 'Quartz Rank' which is supposed to just add the rank of the spell to the Quartz cast bar. Turns out that it over-rides the default GetSpellRank function (no local or prefix on the function) and returns the rank value as a string. And the kicker is that it doesn't even use that function in its own add-on.

Sorry for the false alarm, would have never thought that an add-on would be overriding a built in function like that. Closing this. Thanks for pointing me in the right direction!