Originally Posted by p3lim
Always test something before you ask..
In other words, yes.
|
thanks,
i tried it before, but it didnt work.
therefore i asked wether it is the correct code or not.
edit: ok events work, but i get a different error.
here my code:
Code:
local function PostUpdateHealth(self, event, unit, bar, min, max)
local min, max = UnitHealth(unit), UnitHealthMax(unit)
local bar = self.Health
local d = floor(min/max*100)
if(unit == "player" or unit == "target") then
if(not UnitIsConnected(unit)) then
bar.Text:SetText('Offline')
elseif(UnitIsDead(unit)) then
bar.Text:SetText('Dead')
elseif(UnitIsGhost(unit)) then
bar.Text:SetText('Ghost')
else
if (unit == 'target') then
if (targetshort == true) then
bar.Text:SetText(ShortHp(min))
else
bar.Text:SetText(min)
end
else
if(min ~= max) then
bar.Text:SetText(min)
else
if (UnitMana("player") > 0) then
bar.Text:SetText(min)
elseif (UnitMana("player") == 0) then
bar.Text:SetText()
elseif(UnitAffectingCombat("player") == 1) then
bar.Text:SetText(min)
else
bar.Text:SetText()
end
end
end
end
end
end
Code:
local func = function(settings, self, unit)
...
self:RegisterEvent("UNIT_MANA", PostUpdateHealth)
self:RegisterEvent("UNIT_RAGE", PostUpdateHealth)
self:RegisterEvent("UNIT_ENERGY", PostUpdateHealth)
self:RegisterEvent("UNIT_RUNIC_POWER", PostUpdateHealth)
self:RegisterEvent("PLAYER_REGEN_DISABLED", PostUpdateHealth)
self:RegisterEvent("PLAYER_REGEN_ENABLED", PostUpdateHealth)
self:RegisterEvent("UNIT_MAXMANA", PostUpdateHealth)
self:RegisterEvent("UNIT_MAXRAGE", PostUpdateHealth)
self:RegisterEvent("UNIT_MAXFOCUS", PostUpdateHealth)
self:RegisterEvent("UNIT_MAXENERGY", PostUpdateHealth)
self:RegisterEvent("UNIT_DISPLAYPOWER", PostUpdateHealth)
self:RegisterEvent("UNIT_MAXRUNIC_POWER", PostUpdateHealth)
end
And here you can see my problem:
With Rage = 0:
With Rage > 0 :
as you can see, my targets hp are now the same as my own hp.
:/