Thread Tools Display Modes
08-06-10, 02:10 PM   #1
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
hp text disappear on max health

Hi -

I'm modifying Freeb's awesome oUF layout to my liking and would like to hide the *player only* hp text information on max hp (and have it appear when hp is lost). This is the chunk I was going for in Freeb's ftags.lua:

Code:
oUF.Tags['freeb:hp']  = function(u) 
	local min, max = UnitHealth(u), UnitHealthMax(u)

	if(unit == "player") then
		if(min < max) then
			return siValue(min).."."..math.floor(min/max*100+.5).."%"
		else
			return bar.value:SetText(" ")
		end
	else
	
        return siValue(min).."."..math.floor(min/max*100+.5).."%"		
	
        end

end
No errors, but it doesn't hide the hp info on max health. Any ideas? Thanks.
  Reply With Quote
08-06-10, 02:28 PM   #2
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Take a closer look and you'll see he uses u instead of unit
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.
  Reply With Quote
08-06-10, 02:56 PM   #3
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Hmm. That didn't work. Replaced "unit" with "u" and spawned all sorts of errors.
  Reply With Quote
08-07-10, 06:25 AM   #4
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
Code:
oUF.Tags['freeb:hp']  = function(u) 
    local min, max = UnitHealth(u), UnitHealthMax(u)

    if(u == "player") then
        if(min < max) then
            return siValue(min).."."..math.floor(min/max*100+.5).."%"
        else
            return " "
        end
    else
    
        return siValue(min).."."..math.floor(min/max*100+.5).."%"        
    
        end

end
like that
  Reply With Quote
08-07-10, 09:36 AM   #5
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Thanks guys. Will give it a try.
  Reply With Quote
08-07-10, 12:52 PM   #6
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
having checks for specific units within tags is not the best idea.

Create separate tags and assign them to the specific units in your style function.

e.g.
Code:
oUF.Tags['freeb:hp']  = function(u) 
    local min, max = UnitHealth(u), UnitHealthMax(u)

    return siValue(min).."."..math.floor(min/max*100+.5).."%"        

end
oUF.Tags['freeb:playerhp']  = function(u) 
    local min, max = UnitHealth(u), UnitHealthMax(u)

    if(min < max) then
        return siValue(min).."."..math.floor(min/max*100+.5).."%"
    else
        return " "
    end

end
and in your style function:
Code:
if self.unit == 'player' then
    self:Tag(myhealthtag, '[freeb:playerhp]')
else
    self:Tag(myhealthtag, '[freeb:hp]')
end
  Reply With Quote
08-07-10, 11:12 PM   #7
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
You can remove the following, because it doesnt make any difference.
Code:
else
    return " "
oUF will just return nil if theres nothing returned, and thus hiding the text.
  Reply With Quote
08-08-10, 03:10 AM   #8
Monolit
A Black Drake
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 81
Originally Posted by yj589794 View Post
having checks for specific units within tags is not the best idea.
ehh, may I ask why?

Originally Posted by p3lim
oUF will just return nil if theres nothing returned, and thus hiding the text.
good to know, thanks
  Reply With Quote
08-08-10, 04:27 AM   #9
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Monolit View Post
ehh, may I ask why?
Because it defeats the purpose of having general tags.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-08-10, 06:43 AM   #10
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
Originally Posted by p3lim View Post
You can remove the following, because it doesnt make any difference.
Code:
else
    return " "
oUF will just return nil if theres nothing returned, and thus hiding the text.
Hum yes i missed that, thanks for pointing it out. But it was meant to display the error in the code above (bar.value blabla).
  Reply With Quote
08-08-10, 11:59 AM   #11
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Good to go. Thank again. Amazing how much I have learned about tags just from this exercise.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » hp text disappear on max health


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