A Black Drake
Join Date: Apr 2008
Posts: 88
|
I'm using oUF 1.3
Maybe I didnt give all the infor so this may be a long copy and paste, sorry.
This is what the layout has now concerning names:
-- -------------------------------------------------------------------------------------------------
-- NAME UPDATE
-- -------------------------------------------------------------------------------------------------
local updateName = function(self, event, unit)
if(self.unit ~= unit) then return end
local name = UnitName(unit)
self.Name:SetText(name)
local color
if UnitIsPlayer(unit) then
local _, c = UnitClass(unit)
color = RAID_CLASS_COLORS[c]
else
color = UnitReactionColor[UnitReaction(unit, "player")]
end
if color then
self.Name:SetTextColor(color.r,color.g,color.b,1)
end
if unit=="target" or unit=="targettarget" or unit=="focus" or unit=="pet" then
updateLevel(self, unit, name)
end
end
-- -------------------------------------------------------------------------------------------------
-- HEALTH UPDATE
-- -------------------------------------------------------------------------------------------------
local updateHealth = function(self, event, unit, bar, min, max)
local cur, maxhp = min, max
local missing = maxhp-cur
local d = floor(cur/maxhp*100)
local color
local tmpunitname
if (unit=="pet" or unit == "focus") then
tmpunitname = UnitName(unit)
local count = 4
if tmpunitname and tmpunitname:len() > count then
tmpunitname = tmpunitname:sub(1, count, self)
end
end
if (unit=="target" or unit == "targettarget") then
tmpunitname = UnitName(unit)
local count = 20
if tmpunitname and tmpunitname:len() > count then
tmpunitname = tmpunitname:sub(1, count, self)
end
end
if UnitIsPlayer(unit) then
local _, c = UnitClass(unit)
color = RAID_CLASS_COLORS[c]
else
color = UnitReactionColor[UnitReaction(unit, "player")]
end
if color then
self.Healthpanel:SetBackdropColor(0,0,0,0)
self.Health2:SetVertexColor(color.r,color.g,color.b,1)
self.Name2:SetTextColor(color.r,color.g,color.b,1)
end
if(unit=="pet" or unit == "focus") then
if(self.unit ~= unit) then return end
local min, max = UnitHealth(unit), UnitHealthMax(unit)
self.Health2:SetPoint('LEFT', 56.2 * (min / max), 0)
self.Health2:SetVertexColor(self.ColorGradient(min / max, unpack(self.colors.smooth)))
else
self.Health2:SetPoint('LEFT', 201 * (min / max), 0)
end
if(UnitIsDead(unit)) then
bar.value:SetText"|cffffffffDead|cffff0000!"
self.Health2:SetVertexColor(0,0,0,0)
self.Health:SetStatusBarColor(0,0,0,0)
elseif(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
bar.value:SetText"|cffffffffTapped|cffff0000!"
elseif(UnitIsGhost(unit)) then
bar.value:SetText"|cffffffffGhost|cffff0000!"
self.Health2:SetVertexColor(0,0,0,0)
self.Health:SetStatusBarColor(0,0,0,0)
elseif(not UnitIsConnected(unit)) then
bar.value:SetText"|cffffffffOff|cffff0000!"
self.Health2:SetVertexColor(0,0,0,0)
self.Health:SetStatusBarColor(0,0,0,0)
elseif(unit == "player") then
if(min ~= max) then
bar.value:SetText("|cffff0000-|r"..numberize(missing))
else
bar.value:SetText("|cff98fb98"..numberize(cur))
end
elseif(unit=="target") then
if(min ~= max) then
bar.value:SetFormattedText('|cffffffff%s|r |cff00ff00: |r%d',numberize(cur), (min/max)*100)
self.Name2:SetText(tmpunitname)
else
bar.value:SetText("|cff98fb98"..numberize(cur))
self.Name2:SetText(tmpunitname)
end
elseif(unit=="targettarget") then
if(min ~= max) then
bar.value:SetText("|cffff0000-|r"..numberize(missing))
self.Name2:SetText(tmpunitname)
else
self.Name2:SetText(tmpunitname)
bar.value:SetText("|cff98fb98"..numberize(cur))
end
elseif(unit == "focus") then
if(min ~= max) then
bar.value:SetText("|cffff0000-|r"..numberize(missing))
self.Name2:SetText(tmpunitname)
else
self.Name2:SetText(tmpunitname)
bar.value:SetText("|cff98fb98"..numberize(cur))
end
elseif(unit == "pet") then
bar.value:SetText("|cff98fb98"..numberize(cur))
end
self:UNIT_NAME_UPDATE(event, unit)
end
Now with this setup I can truncate the name to whatever length but it cuts if off at the end of the name.
I guess im not sure where to put the proper codes to get them to work. When I delete everything about (tmpunitname) and add in that code then replace this original line that calls the code (this is the original thats in the layout now before any changes):
-- -------------------------------------------------------------------------------------------------
-- NAME's
-- -------------------------------------------------------------------------------------------------
self.Name = self.Health:CreateFontString(nil, 'OVERLAY')
self.Name:SetWidth(200)
self.Name:SetHeight(fontsize)
self.Name:SetFont(font,fontsize, "OUTLINEMONOCHROME")
self.Name:SetShadowOffset(1,-1)
self.Name:SetShadowColor(0,0,0)
-- -------------------------------------------------------------------------------------------------
-- NAME's
-- -------------------------------------------------------------------------------------------------
self.Name2 = self.Health:CreateFontString(nil, "OVERLAY")
self.Name2:SetWidth(200)
self.Name2:SetHeight(fontsize)
self.Name2:SetFont(font,fontsize, "OUTLINEMONOCHROME")
self.Name2:SetShadowOffset(1,-1)
self.Name2:SetShadowColor(0,0,0)
I get an error that tells me its trying to call "name" but found nil?
I guess I need to know what to delete or change and where to do that ><
I still want my focus and pet to be truncated to 4 characters though.
Geez, I hope this isnt confusing - I am using 1.3 oUF (as that is what Nins is coded from).
thanks all for the help so far!
Maybe thats why Dawns didnt work in mine! Shes using 1.4 - sigh well I dont know what to change to make it work with 1.3
BTW, this code turns to red text in note++ (i thought that meant it was commented out? so.....and I suppose to remove the brackets? I do that - maybe thats why it didnt work? Im so confused ><
oUF.Tags["abbreviatedname"] = [[function(u)
local name = UnitName(u)
return (string.len(name) > 10) and string.gsub(name, "%s?(.)%S+%s", "%1. ") or name
end]]oUF.TagEvents["abbreviatedname"] = "UNIT_NAME_UPDATE"
Last edited by Porsha : 09-07-10 at 09:19 AM.
|