Thread Tools Display Modes
12-18-10, 07:36 PM   #1
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Question Weird tag behaviour is freaking me out

Hey, hope you guys can help me out with this one!

Im trying to create some tags to display my faction standings in my oUF layout but some of them are giving me a headache.

lua Code:
  1. oUF.Tags['drk:currep']  = function(unit)
  2.     local _, _, cur, _, total = GetWatchedFactionInfo()
  3.     if cur and total then
  4.         return total-cur
  5.     end
  6. end
  7. oUF.TagEvents['drk:currep'] = 'UPDATE_FACTION'
  8.  
  9. oUF.Tags['drk:maxrep']  = function(unit)
  10.     local _, _, cur, max = GetWatchedFactionInfo()
  11.     if cur and max then
  12.         return max-cur
  13.     end
  14. end
  15. oUF.TagEvents['drk:maxrep'] = 'UPDATE_FACTION'
This 2 tags sometimes return nil even if i have a watched faction. One simple way to reproduce the error is to chose a faction and then check the "show as experience bar" box... The tags will correctly return the min and max standings for the selected faction... Now try unchecking and checking the same box back again... both tags returns nil.
This only happens when u uncheck/check the same faction. If I uncheck one faction and then check another one the tags return correct values.

The funny thing is that this bug does not happens to the following tag:
lua Code:
  1. oUF.Tags['drk:repstanding']  = function(unit)
  2.     local _, standing = GetWatchedFactionInfo()
  3.     if standing then
  4.         return "(".._G["FACTION_STANDING_LABEL"..standing]..")"
  5.     end
  6. end
  7. oUF.TagEvents['drk:repstanding'] = 'UPDATE_FACTION'
It always return the expected value as long as there's a faction being watched.

Now for the freaking part: if you put this last tag together with one or both of the first (bugged) tags inside the same fontstring, the bug is gone and all tags always returns the expected value.

Please excuse my poor english.
  Reply With Quote
12-19-10, 10:51 AM   #2
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
I'm unable to recreate this. All three tags behave as expected.

You might want to note that, GetWatchedFactionInfo(), returns: nil, 0, 0, 0, 0 when no faction is selected. This can make your drk:repstanding tag error out, as it tries to fetch FACTION_STANDING_LABEL0, which is a nil value. This might be creating the odd behavior for the two other tags.

So, make sure you have Lua errors turned on.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
12-19-10, 05:39 PM   #3
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Yeah, thanks for pointing that out. I've corrected the code. But the problem is still there.

In fact, I created those tags hoping to solve the same problem i was having with ouf_reputation's default tags. I was getting the same nil and zero results from it's tags so i tried creating my own but with no luck.

I even tried disabling every single addon, leaving just ouf, ouf_drk and ouf_reputation but the problem persists.

Here's the code for the plugin:
lua Code:
  1. -- oUF_Reputation
  2. local addRepBar
  3. do
  4.     local PostUpdateRep = function(Reputation, unit, min, max)
  5.         if GetWatchedFactionInfo() then
  6.             local FACTION_BAR_COLORS = {
  7.                 [0] = {r = 1, g = 0.3, b = 0.22},
  8.                 [1] = {r = 0.8, g = 0.3, b = 0.22}, -- hated, dark red
  9.                 [2] = {r = 1, g = 0, b = 0},        -- hostile, bright red
  10.                 [3] = {r = 1, g = 0.5, b = 0},      -- unfriendly, orange
  11.                 [4] = {r = 0.9, g = 0.7, b = 0},    -- neutral, yellow
  12.                 [5] = {r = 0, g = 0.6, b = 0.1},    -- friendly, dark green
  13.                 [6] = {r = 0, g = 1, b = 0},        -- honored, bright green
  14.                 [7] = {r = 0.25, g = 0.4, b = 0.9}, -- reverted, blue
  15.                 [8] = {r = 0.6, g = 0.2, b = 0.8}-- exalted, purple
  16.             }
  17.             local _, id = GetWatchedFactionInfo()
  18.             local r, g, b
  19.             local multiplier = 0.3
  20.            
  21.             r = FACTION_BAR_COLORS[id].r;
  22.             g = FACTION_BAR_COLORS[id].g;
  23.             b = FACTION_BAR_COLORS[id].b;
  24.            
  25.             Reputation:SetStatusBarColor(r, g, b)
  26.             Reputation.bg:SetVertexColor(r * multiplier, g * multiplier, b * multiplier)
  27.         end
  28.     end
  29.  
  30.     lib.addRepBar = function(self)
  31.         if IsAddOnLoaded("oUF_Reputation") then
  32.             -- Rep bar
  33.             local rep = CreateFrame("StatusBar", nil, self)
  34.             rep:SetStatusBarTexture(cfg.statusBarTexture)
  35.             rep:SetHeight(4)
  36.             rep:SetWidth(250)
  37.             rep:SetFrameLevel(1)
  38.             rep:SetPoint("BOTTOMLEFT", self,"TOPLEFT", 0, 8)
  39.            
  40.             local repBG = rep:CreateTexture(nil, "BACKGROUND")
  41.             repBG:SetTexture(cfg.statusBarTexture)
  42.             repBG:SetAllPoints(rep)
  43.             rep.bg = repBG
  44.            
  45.             -- Text display
  46.             local repName= setFont(rep, cfg.smallfont, 13, "OUTLINE", 0)
  47.             repName:SetPoint("LEFT", 0, 5)
  48.             repName:SetPoint("RIGHT", rep, "RIGHT", 0, 5)
  49.             repName:SetJustifyH("CENTER")
  50.             self:Tag(repName, "[drk:currep]/[drk:maxrep] [drk:repstanding] - [reputation]")
  51.            
  52.             createBGFrame(rep, 0)
  53.            
  54.             self.Reputation = rep
  55.             self.Reputation.PostUpdate = PostUpdateRep
  56.         end
  57.     end
  58. end
The bar itself always shows the right ammount of rep and the right color, the problem is just the tags, no matter if i use the plugin's default tags or mine.

Last edited by drakull : 12-19-10 at 06:10 PM.
  Reply With Quote
12-21-10, 11:44 PM   #4
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Any toughts?
  Reply With Quote
12-22-10, 12:23 AM   #5
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
I haven't had any time to do more testing, but the two first tags (min/max) was working fine when I tested, as was the last one when fixed to not throw errors.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
12-22-10, 08:48 AM   #6
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
It must be something I'm doing in my layout. I've rewrited most of the code and now I have noticed this and some other strange behaviours. oUF_DebuffHightlight is also acting weird, wrong colors are being applied to it's frame. And oUF_Experience's rested bar completely fills the bar even if I don't have any rested XP.

Even the built in runebar element sometimes displays permanent death runes, they persist even long time after I leave combat.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Weird tag behaviour is freaking me out


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