-
Posted by Perfexion on Sun, 26 Jul 2009 21:05:19
I am working through chapter 15, and I have ran into a few problems.
First, TargetBuffButtonTemplate and TargetDebuffButtonTemplate have changed to TargetBuffFrameTemplate and TargetDebuffFrameTemplate.
The former is referenced under TargetTextBuffs:CreateBuff() The latter is referenced in the XML where TargetTextBuffsDebuffTemplate inherits it.
Now, I am running into a problem that I have not been able to fix my self.
My UI loads without any problems, but when I target someone who has buffs, swatter throws "attempt to compare number with string" at line 93.
Now, line 109 is under TargetTextBuffs:UpdateBuffsBase(BuffFunc, frames, method)
at line 109, there is:
if duration and duration > 0 then
So, I am getting a string as duration.
Curiously, to help me figure out whats up, I put the following code immediately preceding this: ChatFrame1:AddMessage("icon: "..icon.." count: "..count.." duration: "..duration.." timeLeft: "..timeLeft.." debuffType: "..debuffType.." Index: "..index)
now, I was hoping to be able to see what is up with these values, but when I do this, swatter throws:
"attempt to concatenate local 'debuffType' (a nil value)"
what I suspect is that the TargetTextBuffs:UpdateDebuffs() wrapper is not working correctly. Here is the code copied from my lua file. It should be exactly what is from the book:
function TargetTextBuffs:UpdateBuffs() return self:UpdateBuffsBase( function(index) local icon, count, debuffType, duration, timeLeft = select(3, UnitDebuff("target", index)) return icon, count, duration, timeLeft, debuffType end, debuffFrames, "CreateDebuff" ) end
Somewhere between filling local icon, count, duration, debuffType, duration, and timeLeft and when I ask them to be printed, I lose some (deBuffType is nil, maybe it was never filled at all), and some get switched around (I think, at least. I suspect that is why duration is a string. Maybe UnitDebuff now returns strings, and I must cast duration to a number and then check to see if it is greater than 0)
My TargetTextBuffs:UpdateDebuffs() is also straight from the book.
As I understand it, the TargetTextBuffs:OnEvent() function calls the TargetTextBuffs:UpdateBuffs and TargetTextBuffs:UpdateDebuffs() function. These each in turn call self:UpdateBase() sending UpdateBase() the BuffFunc() (Either UnitBuffs or UnitDebuffs()), the frame to update, and the method.
I just don't see how my icon, count, duration, debuffType, duration, and timeLeft are getting messed up.
-
Posted by Perfexion on Sun, 26 Jul 2009 21:12:30
Okay, I realize that I was trying to concantenate duration, when duration should be a nil value if the buff has no fixed duration (Mount for example).
I also realize now that I only get the error that says I am trying to compare a string to a number when I target someone who has buffs with durations.
-
Posted by Perfexion on Sun, 26 Jul 2009 21:29:25
After adding the code:
if count then ChatFrame5:AddMessage(" count: "..count) else ChatFrame5:AddMessage("count: Nil") end if icon then ChatFrame5:AddMessage(" icon: "..icon) else ChatFrame5:AddMessage("icon: Nil") end if duration then ChatFrame5:AddMessage(" duration: "..duration) else ChatFrame5:AddMessage("duration: Nil") end if timeLeft then ChatFrame5:AddMessage(" timeLeft: "..timeLeft) else ChatFrame5:AddMessage("timeLeft: Nil") end if debuffType then ChatFrame5:AddMessage("debuffType: "..debuffType) else ChatFrame5:AddMessage("debuffType: Nil") end
I noticed that I would get a printout saying "Duration: Magic" "debuffType: Nil"
It seems that duration and debuffType are being switched
I think I am headed in the right direction
-
Posted by Perfexion on Sun, 26 Jul 2009 22:11:06
Okay, I decided to abondon using switch and get all returns from UnitBuff() and UnitDebuff(). I am noticing that I always get a nil for expires.
Here is my code:
function RhoBuffs:UpdateDebuffs() return self:UpdateBuffsBase( function(index) local name, rank, icon, count, dispelType, duration, expires, caster, isStealable = UnitDebuff("target", index) return name, rank, icon, count, dispelType, duration, expires, caster, isStealable end, debuffFrames, "CreateDebuff" ) end
and I am only including the beginning of this:
function RhoBuffs:UpdateBuffsBase(BuffFunc, frames, method) local index = 1 local name, rank, icon, count, dispelType, duration, expires, caster, isStealable = BuffFunc(index) local anchorBuff
Now, my issues are
a) expires always comes back nil from UnitBuffs() or UnitDebuff()
b) when I hover over a buff, I get this from swatter:
Error occured in: Global Count: 1 Message: ...AddOns\Auc-Advanced\Libs\LibExtraTip\LibExtraTip.lua line 252: Usage: GameTooltip:SetUnitBuff("unit", [index] or ["name", "rank"][, "filter"]) Debug: ...AddOns\Auc-Advanced\Libs\LibExtraTip\LibExtraTip.lua:252:
...AddOns\Auc-Advanced\Libs\LibExtraTip\LibExtraTip.lua:246 [string "*:OnEnter"]:1
c) I since I have been messing with my addon, X-Perl has been acting strange, and it persists through UI reloads, even through game client closing and reopening. For instance, I can no longer see buffs on my target frame. I can no longer see the playermodel on my target frame.
Regarding issue b), I believe that because I inherited from TargetBuffFrameTemplate and TargetDebuffFrameTemplate, they have scripts in place to show a popup on a mouseover of a tooltip. When I inherit this, I break the functionality.
-
Posted by jnwhiteh on Sun, 26 Jul 2009 22:29:12
It would really help if you could narrow down your issue, since you seem to be having lots of problems. If you check a buff that you've cast on yourself (or any other buff that shows the default timer countdown on it) then you should get a proper return for expires. I suggest you play with that. It's relatively simple:
/run print(UnitBuff("player", 1)
For example. With regards to your other issues, I don't even know where to begin helping you troubleshoot, since I'm not quite familiar with the way you have things set up.