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

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