Quantcast
Pitbull Text - WoWInterface
Thread Tools Display Modes
12-26-15, 03:20 PM   #1
slayos
A Deviate Faerie Dragon
 
slayos's Avatar
Join Date: May 2015
Posts: 15
Post Pitbull Text

Hello i have a code here wich i want some attention to:

local cur, max = HP(unit), MaxHP(unit)
local PerHP = cur/max
local hr, hg, hb

if (PerHP < 0.5) then
hr = 255
hg = 255 * PerHP * 2
hb = 0
else
hr = 255 * (1 - ((PerHP - 0.5) * 2))
hg = 255
hb = 0
end

return "|cff%02x%02x%02x%s",hr,hg,hb,Short(cur,true)
at the moment it displays my health as (409k)
but i want it to display my health as (409200)
also i want this only on "players"
on otther units such as mobs, npcs i want it to display as (409k)
With Health set to Green at 100% health, Orange at 75% health and Red at 35% health

Last edited by slayos : 12-26-15 at 03:23 PM.
  Reply With Quote
12-27-15, 02:50 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
local hp = HP(unit)
local perc = hp / MaxHP(unit)

return "|cff%s%s",
	perc <= 0.35 and "ff0000"
		or perc <= 0.75 and "ffa500"
		or "00ff00",
	UnitIsPlayer(unit) and hp or Short(hp, true)
I'm not sure if you're allowed to use actual API functions in LuaTexts; if not, you'll have to figure out what the LuaTexts equivalent of UnitIsPlayer is and substitute that.
__________________
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
12-27-15, 06:19 PM   #3
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,359
Originally Posted by Phanx View Post
Code:
local hp = HP(unit)
local perc = hp / MaxHP(unit)

return "|cff%s%s",
	perc <= 0.35 and "ff0000"
		or perc <= 0.75 and "ffa500"
		or "00ff00",
	UnitIsPlayer(unit) and hp or Short(hp, true)
I'm not sure if you're allowed to use actual API functions in LuaTexts; if not, you'll have to figure out what the LuaTexts equivalent of UnitIsPlayer is and substitute that.
Check out PitBull Unit Frames 4.0 - Lua Texts . That's if you don't know already. I don't know if it say's anything about "UnitIsPlayer" though.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Pitbull Text

Thread Tools
Display Modes

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