View Single Post
03-24-15, 10:46 PM   #3
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Originally Posted by Munglunch View Post
So I can't be positive without testing the full code (im at work so I can't for another hour) BUT here is something to hopefully point you in the right direction.

Your event function has no restriction on what unit its referencing aura-wise (not sure how much this matters in context)

I added an extra key to the "indicators" object that can hold the frames unit token

Lua Code:
  1. if cfg.indicators.enable then
  2.         local indicators = CreateFrame("Frame", nil ,self)
  3.         indicators:SetAllPoints(true)
  4.         indicators:EnableMouse(false)
  5.         self.indicators = indicators
  6.         self.indicators.unit = unit
  7.         -- Build the indicators
  8.         for i = 1, #indicatorPositions do
  9.             local position = indicatorPositions[i]
  10.             local indicator = CreateFrame("Frame", nil, indicators)
  11.             indicator:Hide()
  12.             indicator:SetPoint(position)
  13.             indicator:SetSize(5, 5)
  14.             indicator:SetBackdrop(indicatorBackdrop)
  15.             indicator.aura = cfg.indicators["aura"..i]
  16.             indicators[position] = indicator
  17.         end
  18.  
  19.         -- Register the event on the frame itself
  20.         self:RegisterEvent("UNIT_AURA", UpdateIndicators)
  21.     end

...which can then be referenced in the event function. Also don't know if "SetShown" will evaluate a string return as true or not so I altered it slightly.

Lua Code:
  1. local function UpdateIndicators(self, event, unit)
  2.     if(unit ~= self.indicators.unit) then return end
  3.     for i = 1, #indicatorPositions do
  4.         local position = indicatorPositions[i]
  5.         local indicator = self.indicators[position]
  6.         indicator:SetShown(UnitBuff(unit, indicator.aura) ~= nil)
  7.     end
  8. end

..again just to help give perspective.
Perspective is better than nothing
__________________
Tweets YouTube Website
  Reply With Quote