View Single Post
08-27-16, 03:58 AM   #19
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
In the future, please don't quote the entire 1500 lines of a post. If you're replying the post directly before yours in the thread, there's no need for a quote at all. If you're replying to something further back, just quote the 1-3 lines that are most relevant to what you're replying. Scrolling past the whole thing quoted is annoying.

The first 26 lines of your current code don't need to exist. Delete everything up to (but not including) line 27:

Code:
hooksecurefunc("AuraButton_Update", function(self, index, filter)
You should re-read the part of my last post explaining about one-time vs every-time parts of the code. You currently have these in the "only run one time" section:

Code:
            local _, _, _, _, _, duration, expirationTime = UnitAura(PlayerFrame.unit, index, filter)
            BuffStatusBar:SetMinMaxValues(expirationTime - duration, expirationTime)
... but those need to be run every time AuraButton_Update happens, not just the first time. Since you're only setting the bar's min/max values once when you create it, instead of updating them when the button is updated, you should expect bad results (and possibly even errors) later when setting the bar's value to something outside of that original range.

And actually now that I'm looking at it again, the current code doesn't account for buffs that don't have durations. You'll want to do something like this:

Code:
            local _, _, _, _, _, duration, expirationTime = UnitAura(PlayerFrame.unit, index, filter)
            if duration > 0 and expirationTime then
                  -- This aura has a duration:
                  BuffStatusBar:SetMinMaxValues(expirationTime - duration, expirationTime)
            else
                  -- This aura doesn't have a duration:
                  BuffStatusBar:SetMinMaxValues(0, 1)
                  BuffStatusBar:SetValue(1)
            end
This check is pointless:

Code:
    if ABuffFrame then
Remove that, and its corresponding "end". The game doesn't call AuraButton_Update for buttons that don't exist, so this check just clutters up your code.
__________________
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