Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NAME:
- local abbr = Name(unit)
- if abbr:len() > 20 and abbr:find(" ") then
- abbr = abbr:gsub("([^ ]+) +",
- function(text)
- return text:sub(1,1) .. ". "
- end)
- elseif abbr:len() > 20 then
- abbr = abbr:truncate(15)
- else
- abbr = abbr
- end
- return "%s", abbr
- PERCENT HP:
- local health_text = ""
- local c_health, m_health = HP(unit), MaxHP(unit)
- local p_health = Round(Percent(c_health, m_health), 1)
- local hr, hg, hb = 255, 255, 255
- local wr, wg, wb = 255, 150, 0
- local er, eg, eb = 255, 40, 25
- local ewr, ewg, ewb = 255, 100, 100
- local dr, db, db = 192, 192, 192
- local xr, xg, xb = 128, 128, 128
- -- dead
- if Dead(unit) then
- health_text = string.format("|cff%02x%02x%02x%s|r", xr, xg, xb, "XX")
- elseif IsOffline(unit) then
- health_text = string.format("|cff%02x%02x%02x%s|r", dr, dg, db, "OL")
- elseif c_health == m_health then
- health_text = ""
- else
- -- normal
- health_text = string.format("%i", p_health)
- -- execute
- if ceil(p_health) <= 25 then
- health_text = string.format("|cff%02x%02x%02x%i|r", er, eg, eb, p_health)
- end
- -- 10% warnning (over 30% only)
- if ((floor(p_health) % 10) == 0) and p_health >= 40 then
- health_text = string.format("|cff%02x%02x%02x%.1f|r", wr, wg, wb, p_health)
- end
- -- 5% warning (under 35% only)
- if ((floor(p_health) % 5) == 0) and p_health <= 35 then
- health_text = string.format("|cff%02x%02x%02x%.1f|r", wr, wg, wb, p_health)
- end
- -- 5% warning under 25%
- if ((floor(p_health) % 5) == 0) and p_health <= 25 then
- health_text = string.format("|cff%02x%02x%02x%.1f|r", ewr, ewg, ewb, p_health)
- end
- end
- return health_text
- STATS:
- local stats_string = ""
- -- Build the power Display
- local power_names = {[1]="R", [2]="F", [3]="E", [6]="P"}
- local c_power, m_power = Power(unit), MaxPower(unit)
- local pr, pg, pb = PowerColor((select(2,UnitPowerType(unit))))
- local c_p_abbr, c_d_power = VeryShort(c_power)
- local m_p_abbr, m_d_power = VeryShort(m_power)
- local power_text = ""
- c_p_abbr = string.gsub(string.sub(string.format(c_p_abbr, 0), -1), "0", "")
- m_p_abbr = string.gsub(string.sub(string.format(m_p_abbr, 0), -1), "0", "")
- local power_type_i, power_type = UnitPowerType(unit)
- local power_name = power_names[power_type_i]
- local p_abbr = string.sub(power_type, 0, 1)
- if Dead(unit) or IsOffline(unit) or m_power <= 1 then
- power_text = ""
- elseif power_name == "R" or power_name == "P" then
- if c_power == 0 then
- power_text = string.format("")
- else
- power_text = string.format("%i|cff%02x%02x%02x%s|r", c_d_power, pr, pg, pb, power_name)
- end
- elseif power_name == "F" or power_name == "E" then
- if c_power == m_power then
- power_text = string.format("")
- else
- power_text = string.format("%i|cff%02x%02x%02x%s|r", c_d_power, pr, pg, pb, power_name)
- end
- else
- if c_power == m_power then
- power_text = string.format("%i|cff%02x%02x%02x%s|r Mana", c_d_power, pr, pg, pb, c_p_abbr)
- else
- power_text = string.format("|cff%02x%02x%02x%i|r|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r |cff%02x%02x%02x%i|r|cff%02x%02x%02x%s|r",
- 255, 255, 255, c_d_power,
- pr, pg, pb, m_p_abbr,
- 128, 128, 128, "/",
- 255, 255, 255, m_d_power,
- pr, pg, pb, m_p_abbr)
- end
- end
- -- Build the current health display
- local health_text = ""
- local c_health, m_health = HP(unit), MaxHP(unit)
- local hr, hg, hb = 255, 255, 255
- if Percent(c_health, m_health) < 90 then hr, hg, hb = 255, 243, 161 end
- if Percent(c_health, m_health) < 70 then hr, hg, hb = 250, 195, 124 end
- if Percent(c_health, m_health) < 50 then hr, hg, hb = 252, 107, 56 end
- if Percent(c_health, m_health) < 25 then hr, hg, hb = 251, 15, 15 end
- local c_h_abbr, c_d_health = VeryShort(c_health)
- local m_h_abbr, m_d_health = VeryShort(m_health)
- c_h_abbr = string.gsub(string.sub(string.format(c_h_abbr, 0), -1), "0", "")
- m_h_abbr = string.gsub(string.sub(string.format(m_h_abbr, 0), -1), "0", "")
- if Dead(unit) then
- health_text = string.format("|cff%02x%02x%02x%s|r", 128, 128, 128, Dead(unit))
- elseif IsOffline(unit) then
- health_text = string.format("|cff%02x%02x%02x%s|r", 96, 96, 96, Offline(unit))
- elseif c_health < m_health then
- health_text = string.format("%i%s / %i%s Health", c_d_health, c_h_abbr, m_d_health, m_h_abbr)
- health_text = string.format("|cff%02x%02x%02x%i|r|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r |cff%02x%02x%02x%i|r|cff%02x%02x%02x%s|r Health",
- hr, hg, hb, c_d_health,
- 255, 255, 255, c_h_abbr,
- 128, 128, 128, "/",
- hr, hg, hb, m_d_health,
- 255, 255, 255, m_h_abbr)
- elseif m_health > 5 then
- health_text = string.format("|cff%02x%02x%02x%i|r|cff%02x%02x%02x%s|r Health",
- hr, hg, hb, c_d_health,
- 50, 255, 50, c_h_abbr)
- else
- health_text = ""
- end
- -- Build the class / race / level string
- local cr, cg, cb = ClassColor(unit)
- local dr, dg, db = DifficultyColor(unit)
- local ar, ag, ab = HostileColor(unit)
- local class_race_level = string.format("|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r",
- dr, dg, db, Level(unit),
- ar, ag, ab, SmartRace(unit),
- cr, cg, cb, Class(unit))
- if SmartRace(unit) == "Non-combat Pet" or SmartRace(unit) == "Critter" then
- stats_string = string.format("|cff%02x%02x%02x%s|r\n \n \n", 128, 128, 128, SmartRace(unit))
- else
- stats_string = class_race_level .. "\n" .. health_text .. "\n" .. power_text .. "\n"
- end
- return stats_string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement