View Single Post
11-15-15, 02:49 PM   #26
Soulcleaver
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 65
Originally Posted by Phanx View Post
Watch your shift key -- Lua is case sensitive, so "UnRegisterEvent" isn't the same as "UnregisterEvent" and will raise an error because it doesn't exist.

Otherwise, you can just grab the color and set it immediately:

Code:
if Stuf.units.target.hpbar and Stuf.units.target.hpbar.bar then
	hooksecurefunc(Stuf.units.target.hpbar.bar, "SetVertexColor", function(bar, ...)
		self.bg:SetVertexColor(...)
	end)
	self.bg:SetVertexColor(Stuf.units.target.hpbar.bar:GetVertexColor())
	self:UnregisterEvent("PLAYER_TARGET_CHANGED")
end
This worked and gave me 0 lua error.

But i have to have the onLoad script to make it work!

"self:RegisterEvent("PLAYER_TARGET_CHANGED")"

And then the lua provided in "onEvent".

The first target doesn't give me the right color, it's just white, but the second and later gives me the correct color.

But atleast now my first target doesn't give me a lua error :P
  Reply With Quote