Hi all,
I am new to this oUF thing and need your help on this matter. I am trying to store a variable in self and to change it using PostUpdateHealth. But for some reason, I cant seem to make it work. Pls look at codes below:
--[[my postupdatehealth]]--
Code:
local PostUpdateHealth = function(Health, unit, min, max)
local self = Health:GetParent()
self.Ptext:SetText("b") -- <----self.Ptext is always nil ???????
end
--[[ init is called for every unit frame ]]--
Code:
local function init(self)
self:RegisterForClicks('AnyUp')
self:SetScript('OnEnter', UnitFrame_OnEnter)
self:SetScript('OnLeave', UnitFrame_OnLeave)
local Ptext = self:CreateFontString(nil,"OVERLAY")
Ptext:SetFont( "Interface\\AddOns\\oUF_HL2\\ghostsmileys.ttf", 72, "OUTLINE")
Ptext:SetTextColor(0.81, 0.86, 0.77)
Ptext:SetText("a")
self.Ptext = Ptext -- <---trying to store self.Ptext here.
end
--[[ target frame ]]--
Code:
local function CreateTarget(self)
init(self) --
--[[ omit codes to create Health.... etc]]
self.Ptext:SetPoint("CENTER",self,"CENTER") -- <---self.Ptext is ok here
self.Health = Health
self.Health.PostUpdate = PostUpdateHealth
end
I am getting an error saying self.Ptext is undefined. What do I miss? Do I need to change PostUpdateHealth() also to make it work?