To be honest, I don't know why it lags so much for you. The only proposal I have left is to upvalue the function used in pending.
Apparently UnitMana and UnitManaMax are still there (they're just the same as UnitPower and UnitPowerMax). That's why you didn't get any errors there. You have enabled BarFader for the player frame only, that's why you didn't noticed the error GetPetHappiness() produces.
p3lim has a typo and checks for self.BarFaderMinAlpha instead of self.BarFadeMinAlpha, but that way you just got the default value of 0.25 and again no probs.
Frame fading-in on casts does not function (that's a race condition I believe. You could test this with bandaging yourself and using the hearthstone)
Here the code that worked for me
(typo in self.BarFaderMinAlpha fixed, blizz funcs as upvalues, removed useless events, removed GetPetHappiness, used UnitPower instead of UnitMana)
lua Code:
--[[
Shared:
- BarFade [boolean]
- BarFadeMinAlpha [value] default: 0.25
- BarFadeMaxAlpha [value] default: 1
--]]
local UnitPowerType = UnitPowerType
local UnitAffectingCombat = UnitAffectingCombat
local UnitExists = UnitExists
local UnitHealth = UnitHealth
local UnitHealthMax = UnitHealthMax
local UnitPower = UnitPower
local UnitPowerMax = UnitPowerMax
local function pending(self, unit)
local num, str = UnitPowerType(unit)
if(self.Castbar and (self.Castbar.casting or self.Castbar.channeling)) then return true end
if(UnitAffectingCombat(unit)) then return true end
if(UnitExists(unit..'target')) then return true end
if(UnitHealth(unit) < UnitHealthMax(unit)) then return true end
if((str == 'RAGE' or str == 'RUNIC_POWER') and UnitPower(unit) > 0) then return true end
if(str ~= 'RAGE' and str ~= 'RUNIC_POWER' and UnitPower(unit) < UnitPowerMax(unit)) then return true end
end
local function update(self, event, unit)
if(unit and unit ~= self.unit) then return end
if(not pending(self, self.unit)) then
self:SetAlpha(self.BarFadeMinAlpha or 0.25)
else
self:SetAlpha(self.BarFadeMaxAlpha or 1)
end
end
local function enable(self, unit)
if(unit and self.BarFade) then
update(self)
self:RegisterEvent('UNIT_COMBAT', update)
self:RegisterEvent('UNIT_TARGET', update)
self:RegisterEvent('UNIT_HEALTH', update)
self:RegisterEvent('UNIT_POWER', update)
if(self.Castbar) then
self:RegisterEvent('UNIT_SPELLCAST_START', update)
self:RegisterEvent('UNIT_SPELLCAST_FAILED', update)
self:RegisterEvent('UNIT_SPELLCAST_STOP', update)
self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED', update)
self:RegisterEvent('UNIT_SPELLCAST_DELAYED', update)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_START', update)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', update)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_INTERRUPTED', update)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', update)
end
return true
end
end
local function disable(self)
if(self.BarFade) then
self:UnregisterEvent('UNIT_COMBAT', update)
self:UnregisterEvent('UNIT_TARGET', update)
self:UnregisterEvent('UNIT_HEALTH', update)
self:UnregisterEvent('UNIT_POWER', update)
if(self.Castbar) then
self:UnregisterEvent('UNIT_SPELLCAST_START', update)
self:UnregisterEvent('UNIT_SPELLCAST_FAILED', update)
self:UnregisterEvent('UNIT_SPELLCAST_STOP', update)
self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTED', update)
self:UnregisterEvent('UNIT_SPELLCAST_DELAYED', update)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_START', update)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', update)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_INTERRUPTED', update)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', update)
end
end
end
oUF:AddElement('BarFader', update, enable, disable)
There is a small lag when fading in/out, but it's half a second or less for me. Upvalueing the funcs does not make a difference for me either.