Originally Posted by Nynaeve
Would it be difficult to vary the portrait by level, insofar as, if you wanted to use those pictures for level 90, but the old forum avatar pictures for race&class at levels 1-59, 60-69, 70-79, 80-89 respectfully?
|
I took the liberty and batch converted the files to tga
Something like this could work:
lua Code:
local UnitIsPlayer = UnitIsPlayer
local UnitClass = UnitClass
local UnitRace = UnitRace
local UnitSex = UnitSex
local UnitLevel = UnitLevel
local SetPortraitTexture = SetPortraitTexture
local _
local lower = string.lower
local format = string.format
local template = [[avatars\%s-%s-%s-%d]]
local function UnitAvatar(texture, unit)
if UnitIsPlayer(unit) then
local race, class, sex, level, tex
_, class = UnitClass(unit)
_, race = UnitRace(unit)
if race == 'Scourge' then
race = 'Undead'
end
sex = UnitSex(unit) == 3 and 'female' or 'male'
level = UnitLevel(unit)
-- in case we target someone with a question mark, then they are at least 10 levels higher
if not level or level < 1 then
level = UnitLevel('player') + 10;
end
tex = lower(format(template, class, race, sex, level > 79 and 80 or level > 69 and 70 or level > 59 and 60 or 1))
texture:SetTexture(tex)
texture:SetTexCoord(0, 1, 0, 1)
-- In case we want round ones
-- SetPortraitToTexture(texture, tex)
else
SetPortraitTexture(texture, unit)
texture:SetTexCoord(0.15, 0.85, 0.15, 0.85)
end
end