View Single Post
Old 05-27-11, 04:55 PM   #12
Sauerkraut
A Cyclonian
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 46
Well I finally figured out what I was doing wrong. I was trying to put the registerevent lines into the creation code for the arrow rather than in the layout code. If that makes sense. Anyhow it is working. Final code looks like this:

in my lib.lua file
Code:
--set color
lib.setArrowColor = function(self)
	local _, pType = UnitPowerType("player")
	local pcolor = oUF.colors.power[pType] or {.3,.45,.65}
	self.Power.arrow:SetVertexColor(unpack(pcolor))
end
in the player section of my core.lua file
Code:
		self:RegisterEvent("PLAYER_LOGIN", lib.setArrowColor)
		self:RegisterEvent("PLAYER_ENTERING_WORLD", lib.setArrowColor)
		self:RegisterEvent("UNIT_DISPLAYPOWER", lib.setArrowColor)
Big thanks to both of you for helping. I get my head so twisted up some times I think I over complicate things. This code seems much faster for the updates.

New question now, can I use the same sort of RegisterEvent in a tag? It seems now that if my power bar is at full (say in cat form full energy) and I switch to caster form (full mana) it still shows 100 (energy) rather than 6.0k (mana).
Sauerkraut is offline   Reply With Quote