View Single Post
01-28-16, 05:29 PM   #5
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
The logic you posted about is to prevent your loop from doing work on anything not visible. MAX_TARGET_BUFFS, which is the boundary for your loop, is a constant -- 32. self.maxBuffs is the current amount of buffs on the target, but understand that all 32 buff frames exist, and are used dynamically. So, that bit of logic prevents the loop from iterating past what buffs are currently displayed.

The code you posted leaks some very generic variables into the global name space, I posted a cleaned up version.

Lua Code:
  1. hooksecurefunc("TargetFrame_UpdateAuras", function(self)
  2.     for i = 1, MAX_TARGET_BUFFS do
  3.         local _, _, icon, _, dispelType = UnitBuff(self.unit, i)
  4.  
  5.         if (icon and (not self.maxBuffs or i <= self.maxBuffs) ) then
  6.             if (dispelType ~= "Magic") then
  7.                 _G["TargetFrameBuff"..i]:Hide()
  8.             end
  9.         end
  10.     end
  11. end)

Last edited by Clamsoda : 01-28-16 at 06:09 PM.
  Reply With Quote