Thread Tools Display Modes
01-15-14, 12:19 PM   #1
Candiman
A Deviate Faerie Dragon
Join Date: Jan 2006
Posts: 12
Help with oUF Phanx edit

I've been editing the lua for oUF Phanx and have run into a small problem. I'm trying to edit the health and power texts on the frames so the health is anchored to the power. I have managed this on most frames but I run into a problem if my target does not have power, such as some NPCs. 2 screenshots here illustrate the problem.



How I want it to look.




The problem I have.

The original code is

Code:
-------------------------
	-- Health bar and text --
	-------------------------
	local health = ns.CreateStatusBar(self, 24, "RIGHT")
	health:SetPoint("TOPLEFT", self, "TOPLEFT", 1, -1)
	health:SetPoint("TOPRIGHT", self, "TOPRIGHT", -1, -1)
	health:SetPoint("BOTTOM", self, "BOTTOM", 0, 1)
	self.Health = health

	health:GetStatusBarTexture():SetDrawLayer("ARTWORK")
	health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -2, FRAME_HEIGHT * config.powerHeight - 4)

	local healthColorMode = config.healthColorMode
	health.colorClass = healthColorMode == "CLASS"
	health.colorReaction = healthColorMode == "CLASS"
	health.colorSmooth = healthColorMode == "HEALTH"

	local healthBG = config.healthBG
	health.bg.multiplier = healthBG

	if healthColorMode == "CUSTOM" then
		local r, g, b = unpack(config.healthColor)
		health:SetStatusBarColor(r, g, b)
		health.bg:SetVertexColor(r * healthBG, g * healthBG, b * healthBG)
	end

	-- Blizzard bug, UNIT_HEALTH doesn't fire for bossN units in 5.2+
	health.frequentUpdates = unit == "boss"

	health.PostUpdate = ns.PostUpdateHealth
	self:RegisterForMouseover(health)

	---------------------------
	-- Predicted healing bar --
	---------------------------
	local heals = ns.CreateStatusBar(self)
	heals:SetAllPoints(self.Health)
	heals:SetAlpha(0.25)
	heals:SetStatusBarColor(0, 1, 0)
	heals:Hide()
	self.HealPrediction = heals

	heals:SetFrameLevel(self.Health:GetFrameLevel())

	heals.bg:ClearAllPoints()
	heals.bg:SetTexture("")
	heals.bg:Hide()
	heals.bg = nil

	heals.ignoreSelf = config.ignoreOwnHeals
	heals.maxOverflow = 1

	heals.Override = ns.UpdateIncomingHeals

	------------------------
	-- Power bar and text --
	------------------------
	if uconfig.power then
		local power = ns.CreateStatusBar(self, (uconfig.width or 1) > 0.75 and 16, "LEFT")
		power:SetFrameLevel(self.Health:GetFrameLevel() + 2)
		power:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 1, 1)
		power:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -1, 1)
		power:SetHeight(FRAME_HEIGHT * config.powerHeight)
		self.Power = power

		health:SetPoint("BOTTOM", power, "TOP", 0, 1)

		if power.value then
			power.value:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 4, FRAME_HEIGHT * config.powerHeight - 2)
			power.value:SetPoint("BOTTOMRIGHT", self.Health.value, "BOTTOMLEFT", -8, 0)
			self:RegisterForMouseover(power)
		end

		local powerColorMode = config.powerColorMode
		power.colorClass = powerColorMode == "CLASS"
		power.colorReaction = powerColorMode == "CLASS"
		power.colorPower = powerColorMode == "POWER"

		local powerBG = config.powerBG
		power.bg.multiplier = powerBG

		if powerColorMode == "CUSTOM" then
			local r, g, b = unpack(config.powerColor)
			power:SetStatusBarColor(r, g, b)
			power.bg:SetVertexColor(r / powerBG, g / powerBG, b / powerBG)
		end

		power.frequentUpdates = unit == "player" or unit == "boss"
		power.PostUpdate = ns.PostUpdatePower
	end

	-----------------------------------------------------------
	-- Overlay to avoid reparenting stuff on powerless units --
	-----------------------------------------------------------
	self.overlay = CreateFrame("Frame", nil, self)
	self.overlay:SetAllPoints(self)
	self.overlay:SetFrameLevel(self.Health:GetFrameLevel() + (self.Power and 3 or 2))

	health.value:SetParent(self.overlay)
	self:SetBorderParent(self.overlay)
My LUA text is here

Code:
-------------------------
	-- Health bar and text --
	-------------------------
	local health = ns.CreateStatusBar(self, 26, "RIGHT")
	health:SetPoint("TOPLEFT", self, "TOPLEFT", 1, -1)
	health:SetPoint("TOPRIGHT", self, "TOPRIGHT", -1, -1)
	health:SetPoint("BOTTOM", self, "BOTTOM", 0, 1)
	self.Health = health

	health:GetStatusBarTexture():SetDrawLayer("ARTWORK")
	

	local healthColorMode = config.healthColorMode
	health.colorClass = healthColorMode == "CLASS"
	health.colorReaction = healthColorMode == "CLASS"
	health.colorSmooth = healthColorMode == "HEALTH"

	local healthBG = config.healthBG
	health.bg.multiplier = healthBG

	if healthColorMode == "CUSTOM" then
		local r, g, b = unpack(config.healthColor)
		health:SetStatusBarColor(r, g, b)
		health.bg:SetVertexColor(r * healthBG, g * healthBG, b * healthBG)
	end

	-- Blizzard bug, UNIT_HEALTH doesn't fire for bossN units in 5.2+
	health.frequentUpdates = unit == "boss"

	health.PostUpdate = ns.PostUpdateHealth
	self:RegisterForMouseover(health)
	
	---------------------------
	-- Predicted healing bar --
	---------------------------
	local heals = ns.CreateStatusBar(self)
	heals:SetAllPoints(self.Health)
	heals:SetAlpha(0.25)
	heals:SetStatusBarColor(0, 1, 0)
	heals:Hide()
	self.HealPrediction = heals

	heals:SetFrameLevel(self.Health:GetFrameLevel())

	heals.bg:ClearAllPoints()
	heals.bg:SetTexture("")
	heals.bg:Hide()
	heals.bg = nil

	heals.ignoreSelf = config.ignoreOwnHeals
	heals.maxOverflow = 1

	heals.Override = ns.UpdateIncomingHeals
	
	------------------------
	-- Power bar and text --
	------------------------
	if uconfig.power then
		local power = ns.CreateStatusBar(self, (uconfig.width or 1) > 0.75 and 22, "RIGHT")
		power:SetFrameLevel(self.Health:GetFrameLevel() + 2)
		power:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 1, 1)
		power:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -1, 1)
		power:SetHeight(FRAME_HEIGHT * config.powerHeight)
		self.Power = power

		health:SetPoint("BOTTOM", power, "TOP", 0, 1)

		if power.value then
			power.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 2, 6)
			--power.value:SetPoint("BOTTOMRIGHT", self.Health.value, "BOTTOMLEFT", -8, 0)
			self:RegisterForMouseover(power)
		end
		
		--if health.value then
		if unit == "player" or unit == "target" or unit == "boss" then
			health.value:SetPoint("BOTTOMRIGHT", power.value, "BOTTOMLEFT", -2, -1) 
		else
		health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 2, 5)
			--self:RegisterForMouseover(health)
		end
		

		local powerColorMode = config.powerColorMode
		power.colorClass = powerColorMode == "CLASS"
		power.colorReaction = powerColorMode == "CLASS"
		power.colorPower = powerColorMode == "POWER"

		local powerBG = config.powerBG
		power.bg.multiplier = powerBG

		if powerColorMode == "CUSTOM" then
			local r, g, b = unpack(config.powerColor)
			power:SetStatusBarColor(r, g, b)
			power.bg:SetVertexColor(r / powerBG, g / powerBG, b / powerBG)
		end

		power.frequentUpdates = unit == "player" or unit == "boss"
		power.PostUpdate = ns.PostUpdatePower
	end

	

	-----------------------------------------------------------
	-- Overlay to avoid reparenting stuff on powerless units --
	-----------------------------------------------------------
	self.overlay = CreateFrame("Frame", nil, self)
	self.overlay:SetAllPoints(self)
	self.overlay:SetFrameLevel(self.Health:GetFrameLevel() + (self.Power and 3 or 2))

	health.value:SetParent(self.overlay)
	self:SetBorderParent(self.overlay)
I'm really hoping someone can help me with this.

P.S Go easy I'm a LUA noob

Last edited by Candiman : 01-15-14 at 12:50 PM. Reason: I suck at images
  Reply With Quote
01-15-14, 09:34 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Rather than editing the initial position of the health text, you should just move it in the PostUpdatePower function, in the same place where the power bar is hidden/shown depending on whether the unit has power or not.

Code:
-- Functions.lua, lines 187 onward, lines in green are what to add/change:
function ns.PostUpdatePower(self, unit, cur, max)
	local frame = self.__owner
	if max == 0 then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint(...) -- add your preferred point here for units with no power
		frame.Health:SetPoint("BOTTOM", self.__owner, "BOTTOM", 0, 1)
		return self:Hide()
	elseif not self:IsShown() then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint(...) -- add your preferred point here for units with power
		frame.Health:SetPoint("BOTTOM", self, "TOP", 0, 1)
		self:Show()
	end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-16-14, 03:12 AM   #3
Candiman
A Deviate Faerie Dragon
Join Date: Jan 2006
Posts: 12
I tried your code with these values.

Code:
function ns.PostUpdatePower(self, unit, cur, max)
	local frame = self.__owner
	if max == 0 then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 2, 5)
		self.__owner.Health:SetPoint("BOTTOM", self.__owner, "BOTTOM", 0, 1)
		return self:Hide()
	elseif not self:IsShown() then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", power.value, "BOTTOMRIGHT", 2, 2)
		frame.Health:SetPoint("BOTTOM", self, "TOP", 0, 1)
		self:Show()
	end
but it returns this error when I target a target with power after targeting a unit with no power.

19x oUF_Phanx-5.4.2.410\Functions.lua:197: attempt to index global "power" (a nil value)
oUF_Phanx-5.4.2.410\Functions.lua:197: in function <oUF_Phanx\Functions.lua:188>
(tail call): ?
(tail call): ?
oUF-1.6.6\ouf-1.6.6.lua:158: in function "func"
oUF-1.6.6\events.lua:48: in function <oUF\events.lua:46>
(tail call): ?
<in C code>
FrameXML\SecureTemplates.lua:497: in function "handler"
FrameXML\SecureTemplates.lua:633: in function "SecureActionButton_OnClick"
FrameXML\SecureTemplates.lua:673: in function <FrameXML\SecureTemplates.lua:665>

Locals:
(*temporary) = "LeftButton"
(*temporary) = false
(*temporary) = <function> defined =[C]:-1
  Reply With Quote
01-16-14, 04:00 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Look at the code you posted, on the line the error message indicates. You have a reference to "power.value" -- but you never defined any variable named "power". I assume you mean the power bar, which in that context is already assigned to the variable "self", so you could fix the error by changing "power.value" to "self.value".

(Also, change the rest of those "self.__owner"s to "frame"; the whole point of creating that variable was to avoid adding a bunch of duplicate table lookups.)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-16-14, 04:05 AM   #5
Candiman
A Deviate Faerie Dragon
Join Date: Jan 2006
Posts: 12
No I'm trying to parent the health text to the power text so that it stays a set distance from the power text.
  Reply With Quote
01-16-14, 04:13 AM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Yes, I'm aware of what you want to do. However, in Lua -- as with any programming language ever devised -- you cannot use a variable without defining it first. When you type the word "power" the game's Lua interpreter does not magically know that you mean "the power bar on the unit frame created by the addon oUF_Phanx for the unit whose UNIT_POWER event caused the addon oUF to run the currently-running function".

As I pointed out in my last post, the variable (word) "self" is already defined as pointing to the frame's power bar in the scope (context) where you are trying to use it, so just change the word "power" to "self" and the game will actually know what you want it to do.

If you really want to use the word "power" instead of "self" there, you need to define a "power" variable in the same scope first, eg.

Code:
function ns.PostUpdatePower(self, unit, cur, max)
	local frame = self.__owner
	local power = self -- completely pointless but you can do it if you want
	if max == 0 then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 2, 5)
		frame.Health:SetPoint("BOTTOM", frame, "BOTTOM", 0, 1)
		return self:Hide()
	elseif not self:IsShown() then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", power.value, "BOTTOMRIGHT", 2, 2)
		-- really you should just change "power" to "self" here, but whatever floats your boat
		frame.Health:SetPoint("BOTTOM", self, "TOP", 0, 1)
		self:Show()
	end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-16-14, 05:03 AM   #7
Candiman
A Deviate Faerie Dragon
Join Date: Jan 2006
Posts: 12
I'm sorry you're being really helpful and I feel like the biggest noob. I added the code as you said then parented the health text to the power text in Frames.LUA. I had to move the health text below the power text in Frames to get it to work but what happens is after I target a powerless unit and the target a unit with power the health text appears over the power text.

The code from functions.lua

Code:
function ns.PostUpdatePower(self, unit, cur, max)
	local frame = self.__owner
	if max == 0 then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 0, 2)
		frame.Health:SetPoint("BOTTOM", self.__owner, "BOTTOM", 0, 1)
		return self:Hide()
	elseif not self:IsShown() then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 2, 6)
		frame.Health:SetPoint("BOTTOM", self, "TOP", 0, 1)
		self:Show()
	end

The changes I made in Frames.lua

Code:
-------------------------
	-- Health bar and text --
	-------------------------
	local health = ns.CreateStatusBar(self, 24, "RIGHT")
	health:SetPoint("TOPLEFT", self, "TOPLEFT", 1, -1)
	health:SetPoint("TOPRIGHT", self, "TOPRIGHT", -1, -1)
	health:SetPoint("BOTTOM", self, "BOTTOM", 0, 1)
	self.Health = health

	

	-- Blizzard bug, UNIT_HEALTH doesn't fire for bossN units in 5.2+
	health.frequentUpdates = unit == "boss"

	health.PostUpdate = ns.PostUpdateHealth
	self:RegisterForMouseover(health)

	---------------------------
	-- Predicted healing bar --
	---------------------------
	local heals = ns.CreateStatusBar(self)
	heals:SetAllPoints(self.Health)
	heals:SetAlpha(0.25)
	heals:SetStatusBarColor(0, 1, 0)
	heals:Hide()
	self.HealPrediction = heals

	heals:SetFrameLevel(self.Health:GetFrameLevel())

	heals.bg:ClearAllPoints()
	heals.bg:SetTexture("")
	heals.bg:Hide()
	heals.bg = nil

	heals.ignoreSelf = config.ignoreOwnHeals
	heals.maxOverflow = 1

	heals.Override = ns.UpdateIncomingHeals

	------------------------
	-- Power bar and text --
	------------------------
	if uconfig.power then
		local power = ns.CreateStatusBar(self, (uconfig.width or 1) > 0.75 and 16, "LEFT")
		power:SetFrameLevel(self.Health:GetFrameLevel() + 2)
		power:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 1, 1)
		power:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -1, 1)
		power:SetHeight(FRAME_HEIGHT * config.powerHeight)
		self.Power = power

		health:SetPoint("BOTTOM", power, "TOP", 0, 1)

		if power.value then
			--power.value:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 4, FRAME_HEIGHT * config.powerHeight - 2)
			power.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -2, 6)
			self:RegisterForMouseover(power)
		end
		
		health:GetStatusBarTexture():SetDrawLayer("ARTWORK")
	health.value:SetPoint("BOTTOMRIGHT", power.value, "BOTTOMLEFT", -2, -2)

	local healthColorMode = config.healthColorMode
	health.colorClass = healthColorMode == "CLASS"
	health.colorReaction = healthColorMode == "CLASS"
	health.colorSmooth = healthColorMode == "HEALTH"

	local healthBG = config.healthBG
	health.bg.multiplier = healthBG

	if healthColorMode == "CUSTOM" then
		local r, g, b = unpack(config.healthColor)
		health:SetStatusBarColor(r, g, b)
		health.bg:SetVertexColor(r * healthBG, g * healthBG, b * healthBG)
	end

		local powerColorMode = config.powerColorMode
		power.colorClass = powerColorMode == "CLASS"
		power.colorReaction = powerColorMode == "CLASS"
		power.colorPower = powerColorMode == "POWER"

		local powerBG = config.powerBG
		power.bg.multiplier = powerBG

		if powerColorMode == "CUSTOM" then
			local r, g, b = unpack(config.powerColor)
			power:SetStatusBarColor(r, g, b)
			power.bg:SetVertexColor(r / powerBG, g / powerBG, b / powerBG)
		end

		power.frequentUpdates = unit == "player" or unit == "boss"
		power.PostUpdate = ns.PostUpdatePower
	end
A screenshot of how it ends up looking



Again I'm sorry for being such a noob.
  Reply With Quote
01-16-14, 05:12 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Sigh. The only change you need to make from the code you posted last time (with the error message) was to change the word "power" to the word "self" instead. Don't change the whole "power.value" to just "self" -- you're only changing the "power" part, so you end up with "self.value" there. Don't overthink it.

However, you might want to change your vertical offset (the last number passed to SetPoint) so that it's the same in both cases. Otherwise, your health text is going to jump up and down a few pixels when the power text appears or disappears. Just change the horizontal offset (the first number) to move the text left (negative values) or right (positive values).
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-16-14, 05:52 AM   #9
Candiman
A Deviate Faerie Dragon
Join Date: Jan 2006
Posts: 12
I'm sorry as I think I'm really starting to annoy you but I'm not sure I'm making myself all that clear. I'm trying to make the health text a child of the power text so that it moves and keeps a constant distance from the power text. If I'm misunderstanging you I'm really sorry but I have a little knowledge of LUA, probably just enough to get me into trouble .

Here is a funny cat for your trouble.

http://www.funnycatsite.com/videos/the-bag-cat.htm
  Reply With Quote
01-16-14, 05:59 AM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Yes. I know that. The code you posted will do that if you just make the one simple change I told you to make. I'm only annoyed because I gave you the solution 2 hours ago, and you keep coming back and saying "no, no, I want to do X". I know you want to do X. I told you how to do X. Stop telling me you want to do X, and just go do it.

Go back to the code you had that gave you the error, and change "power.value" to "self.value". Do not change anything else.

If you've already made that change and no other changes, and are now seeing a result that is not X, you need to be more specific about what you are seeing.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-16-14, 06:07 AM   #11
Candiman
A Deviate Faerie Dragon
Join Date: Jan 2006
Posts: 12
I am very sorry this is probably my lack of knowledge in LUA. With a fresh install with just the changes in Functions.lua you posted.

Code:
function ns.PostUpdatePower(self, unit, cur, max)
	local frame = self.__owner
	if max == 0 then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -2, 0)
		frame.Health:SetPoint("BOTTOM", self.__owner, "BOTTOM", 0, 1)
		return self:Hide()
	elseif not self:IsShown() then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 4, 0)
		frame.Health:SetPoint("BOTTOM", self, "TOP", 0, 1)
		self:Show()
	end
I get this.

  Reply With Quote
01-16-14, 06:22 AM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
No, those are not the changes I posted. Those are the changes you posted after I told you to change "power" to "self", and you changed "power.value" to "self" instead of only the "power" part. Here is the code you posted with the error message earlier:

Code:
function ns.PostUpdatePower(self, unit, cur, max)
	local frame = self.__owner
	if max == 0 then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 2, 5)
		self.__owner.Health:SetPoint("BOTTOM", self.__owner, "BOTTOM", 0, 1)
		return self:Hide()
	elseif not self:IsShown() then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", power.value, "BOTTOMRIGHT", 2, 2)
		frame.Health:SetPoint("BOTTOM", self, "TOP", 0, 1)
		self:Show()
	end
The word "power" -- the thing that caused the error -- is highlighted in bright blue. Change that word -- just that word, not the ".value" that comes after it, or anything else -- to "self". Voila! Your code now works as you intended.

Some other changes you might want to make to the above code, after you have verified that fixing the variable name makes it work the way you want:

(1) Change both instances of "self.__owner" in the 6th line -- highlighted above in orange -- to "frame". This will not change any functionality, but it will make the code slightly faster.

(2) Change the vertical offsets -- the last number -- in your "frame.Health.value:SetPoint" lines so that they are the same number. This will make it so that your text doesn't jump up and down by 4px when you only want to move it left or right. Based on your screenshots, I would suggest changing the 5 (highlighted above in pink) to a 2, not the other way around.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-16-14, 06:39 AM   #13
Candiman
A Deviate Faerie Dragon
Join Date: Jan 2006
Posts: 12
Thank you so much for your patience. We have progress.This is the code I have now.

Code:
function ns.PostUpdatePower(self, unit, cur, max)
	local frame = self.__owner
	if max == 0 then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -2, 0)
		frame.Health:SetPoint("BOTTOM", frame, "BOTTOM", 0, 1)
		return self:Hide()
	elseif not self:IsShown() then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self.value, "BOTTOMLEFT", -2, 0)
		frame.Health:SetPoint("BOTTOM", self.value, "TOP", 0, 1)
		self:Show()
	end
When I come into game and target a unit with power I get



Then if I target a powerless unit I get



then if I target a unit with power I get



It seems to only be updating after I target a powerless unit and then it's breaking the Target's target frame.
  Reply With Quote
01-16-14, 06:45 AM   #14
Candiman
A Deviate Faerie Dragon
Join Date: Jan 2006
Posts: 12
It also appears to be doing something strange to the target frame. I changed the texture to make it more obvious.

  Reply With Quote
01-16-14, 06:57 AM   #15
Candiman
A Deviate Faerie Dragon
Join Date: Jan 2006
Posts: 12
I am a noob I spotted the mistake that was breaking the target and Target's target texture but the health is still showing up the way I posted above.This is the code I have now.

Code:
function ns.PostUpdatePower(self, unit, cur, max)
	local frame = self.__owner
	if max == 0 then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -2, 0)
		frame.Health:SetPoint("BOTTOM", frame, "BOTTOM", 0, 1)
		return self:Hide()
	elseif not self:IsShown() then
		frame.Health.value:ClearAllPoints()
		frame.Health.value:SetPoint("BOTTOMRIGHT", self.value, "BOTTOMLEFT", -2, 0)
		frame.Health:SetPoint("BOTTOM", self, "TOP", 0, 1)
		self:Show()
	end
  Reply With Quote
01-16-14, 07:16 AM   #16
Candiman
A Deviate Faerie Dragon
Join Date: Jan 2006
Posts: 12
Managed to work this out myself. I had to make some changes in Frames.lua to position the health text. Thank you again for all your help Phanx you were very patient with this complete noob.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Help with oUF Phanx edit


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off