View Single Post
01-12-15, 02:36 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You're putting your code in the wrong place. Right now you've got it in the part that creates the aura icons when you first log in -- at that point, you'll never have a target, so your (nonexistent) target will never be an enemy, so you'll always be setting the size to 24. Instead, you need to put your code somewhere that will be checked over and over during gameplay to catch target changes.

Fortunately, the Auras/Buffs/Debuffs element supports several callbacks that make this easy. I'd suggest something like this:

Code:
function b:PreSetPosition()
     local size = UnitIsEnemy("player", self.__owner.unit) and 50 or 24
     if size == self.size then return end -- no need to continue
     self.size = size -- set the new size
     self:SetSize(size*b.num/2+b.spacing*(b.num/2-1), size) -- resize the container
     return 1 -- to force oUF to reposition all the icons
end
You can put that where you have your current code, and oUF will automatically call it each time it updates the icons.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote