Thread Tools Display Modes
Prev Previous Post   Next Post Next
08-15-14, 07:29 AM   #21
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
sure okay, that makes sense. I think I was having issues because i'd swapped a few things round to get it working before (note: not the version i'm using now):

Lua Code:
  1. --
  2. --
  3.  
  4.     local fontstring = frame:CreateFontString(nil, "ARTWORK")
  5.     local fontstrings = {}
  6.    
  7.     frame:SetScript("OnEvent", function(self, event, ...)        
  8.         local shown = 0
  9.        
  10.         -- hide any unused ones first
  11.         for i = shown + 1, #fontstrings do
  12.             fontstrings[i]:Hide()
  13.         end
  14.        
  15.         for i = 1, #cfg.spells do
  16.             local spell = cfg.spells[i]
  17.             local _, _, _, stacks = UnitBuff("player", spell.name)
  18.             if stacks and spell.show==true then
  19.                
  20.                 shown = shown + 1
  21.                 local fontstring = frame:CreateFontString(nil, "ARTWORK")
  22.                 fontstrings[shown] = fontstring -- keep them all in another indexed table
  23.                 fontstring:SetFont(STANDARD_TEXT_FONT, spell.size, "OUTLINE")
  24.                 fontstring:SetShadowOffset(0, 0)
  25.                 fontstring:SetText(string.rep(spell.symbol, stacks > 0 and stacks or 1))
  26.                 fontstring:SetTextColor(spell.colour[1], spell.colour[2], spell.colour[3])
  27.                 fontstring:ClearAllPoints()
  28.                 if shown > 1 then
  29.                     fontstring:SetPoint("BOTTOMRIGHT", fontstrings[shown - 1], "TOPRIGHT", 0, -5)
  30.                 else
  31.                     fontstring:SetPoint("RIGHT", UIParent, "CENTER", 96, 75)
  32.                 end
  33.                 fontstring:SetJustifyH("RIGHT")
  34.                 fontstring:SetSpacing(2)
  35.                 fontstring:Show()
  36.             end
  37.         end
  38.     end)
  39. --
  40. --

Anyway, i've just tried this new method. Here's the full code:

https://gist.github.com/anonymous/1bcb3a092180fa6cf71b

Getting:

Code:
1x SpellActivationOverlay.lua:43: attempt to index global "fontstrings" (a nil value)
whenever more than one string tries to show.

Last edited by ObbleYeah : 08-15-14 at 07:34 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » checking for buff stacks in C_L_E_U


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