Trying to get a custom script working, to use with Pitbull4. This script modifies the color and length of unit frame names.
The code i have currently does everything correctly, except when targeting NPCs, its using class colors and i am hoping to find a way to get it to color the text by hostility for NPCs.
The code i am using now:
local abbr = Name(unit); if abbr:len() > 19 and abbr:find(" ") then abbr = abbr:gsub("([^ ]+) +", function(text) return text:sub(1,1) .. ". "; end ) end
local r,g,b = ClassColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end
The code for coloring by hostility is:
local r,g,b = HostileColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end
I have tried merging these several different ways, sometimes with errors, sometimes without, but unable to produce a working script.
If anyone is bored and wouldnt mind showing me how to correctly merge these scripts, would be greatly appreciated. Just not sure of the correct syntax use.
Code i have been trying:
local abbr = Name(unit); if abbr:len() > 19 and abbr:find(" ") then abbr = abbr:gsub("([^ ]+) +", function(text) return text:sub(1,1) .. ". "; end ) end
if UnitIsPlayer(unit) then
local r,g,b = ClassColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end
elseif UnitIsEnemy(unit, "otherunit") then
local r,g,b = HostileColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end end
This will class color friendly players, but leaves the text blank if i target hostile npcs or friendly NPCs.
I know very little about lua, but after hours of reading through others scripts and the api site, this is what i have come up with:
ThickOutline()
local abbr = Name(unit); if abbr:len() > 19 and abbr:find(" ") then abbr = abbr:gsub("([^ ]+) +", function(text) return text:sub(1,1) .. ". "; end ) end
if UnitIsPlayer(unit) then
local r,g,b = ClassColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end
elseif ( UnitClassification("target") == "normal" ) then
local r,g,b = HostileColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end
elseif ( UnitClassification("target") == "worldboss" ) then
local r,g,b = HostileColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end
elseif ( UnitClassification("target") == "rareelite" ) then
local r,g,b = HostileColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end
elseif ( UnitClassification("target") == "elite" ) then
local r,g,b = HostileColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end
elseif ( UnitClassification("target") == "rare" ) then
local r,g,b = HostileColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end
elseif ( UnitClassification("target") == "trivial" ) then
local r,g,b = HostileColor(unit) if string.len(Name(unit)) > 30 then return '|cff%02x%02x%02x%s...|r ',r,g,b,string.sub(abbr,1,9) else return '|cff%02x%02x%02x%s|r ',r,g,b,abbr end
end
I'm sure there are much better ways to write it, but this does exactly what i want it to do.
Now i am trying to figure out how to fix up this code:
Outline()
local s=Status(unit)
if s then
return s
else
local cur,max=Power(unit),MaxPower(unit)
if cur~=max then
return "%s|cff69ccf0%%",Round(Percent(cur,max),0)
end
end
Works perfectly for casters, but when targeting a DK, Warrior, Rogue, Druid, etc... anything without a mana bar, the display shows up incorrectly (or atleast not what i am wanting).
For a warrior with a rage bar, when the warrior has 0 rage, its displaying 0%. With rage it shows current rage with a % added to the end.
So i am wanting to get rid of the % sign, for any non mana using class. Also when a warrior / dk is sitting at 0 rage / runic, the power text should be hidden, not showing 0%.
I will keep trying, im sure i can figure it out, just takes a really long time ;p
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
The code i have currently does everything correctly, except when targeting NPCs, its using class colors and i am hoping to find a way to get it to color the text by hostility for NPCs.
The code i am using now:
The code for coloring by hostility is:
I have tried merging these several different ways, sometimes with errors, sometimes without, but unable to produce a working script.
If anyone is bored and wouldnt mind showing me how to correctly merge these scripts, would be greatly appreciated. Just not sure of the correct syntax use.
Code i have been trying:
This will class color friendly players, but leaves the text blank if i target hostile npcs or friendly NPCs.
Have you tried
(is the target hostile to the player?)
I'm sure there are much better ways to write it, but this does exactly what i want it to do.
Now i am trying to figure out how to fix up this code:
Works perfectly for casters, but when targeting a DK, Warrior, Rogue, Druid, etc... anything without a mana bar, the display shows up incorrectly (or atleast not what i am wanting).
For a warrior with a rage bar, when the warrior has 0 rage, its displaying 0%. With rage it shows current rage with a % added to the end.
So i am wanting to get rid of the % sign, for any non mana using class. Also when a warrior / dk is sitting at 0 rage / runic, the power text should be hidden, not showing 0%.
I will keep trying, im sure i can figure it out, just takes a really long time ;p