1)
Code:
local GetLevelText(unit)
if ( UnitIsWildBattlePet(unit) or UnitIsBattlePetCompanion(unit) ) then
return '|cffffffff'..UnitBattlePetLevel(unit)..'|r'
elseif level == UnitLevel('player') then
return '|cffffffff'..level..'|r'
elseif(level > 0) then
return '|cffffffff'..level.."|r"
else
return '|cffffffff??|r'
end
end
Code:
local __colors = {
[1] = { 0.78, 0.25, 0.25, 1 },
[2] = { 0.78, 0.25, 0.25, 1 },
[3] = { 0.78, 0.25, 0.25, 1 },
[4] = { 218/255, 197/255, 92/255 },
[5] = { 75/255, 175/255, 76/255 },
[6] = { 75/255, 175/255, 76/255 },
[7] = { 75/255, 175/255, 76/255 },
[8] = { 75/255, 175/255, 76/255 },
}
local function GetNameColor(unit)
local unitReaction = UnitReaction(unit, 'player')
local _, unitClass = UnitClass(unit)
if (UnitIsPlayer(unit)) then
local class = RAID_CLASS_COLORS[unitClass]
if class then return '|c'..RAID_CLASS_COLORS[unitClass].colorStr end
return '|cFFFFFFFF'
elseif (unitReaction) then
local reaction = __colors[unitReaction]
return format("|cff%02x%02x%02x", reaction[1]*255, reaction[2]*255, reaction[3]*255)
else
return '|cFFC2C2C2'
end
end
Code:
local text = format('%s %s %s|r', GetLevelText(unit), GetNameColor(unit), ( UnitName(unit) ))
2)
Code:
local function ShortValue(v)
if v >= 1e9 then
return ("%.0fb"):format(v / 1e9)
elseif v >= 1e6 then
return ("%.0fm"):format(v / 1e6)
elseif v >= 1e3 or v <= -1e3 then
return ("%.0fk"):format(v / 1e3)
else
return v
end
end
Code:
local function GetHPPerc(unit)
local hp = UnitExists(unit) and ( UnitHealth(unit) / UnitHealthMax(unit) ) * 100 or 0
if hp >= 100 then
return ''
else
return format("%.1f%s", hp, "%%")
end
end
Code:
local text = format("%s %s", ShortValue(UnitHealthMax(unit)), GetHPPerc(unit))