So I'm using this code to display mini health values when a raid member is missing health. How can I get it to display "dead"/"ghost" in place of a numerical value, but without the timer? Thanks!
Outline()
local s = Status(unit)
if s then
return s
end
local cur, max = HP(unit), MaxHP(unit)
if UnitIsFriend(unit,"player") then
local miss = max - cur
if miss ~= 0 then
return "|cffffacac-%s|r",VeryShort(miss,true)
else
return ''
end
else
return "%s/%s",VeryShort(cur,true),VeryShort(max,true)
end
As you can see, the health display is behaving properly for players nearby, such as the shaman in the bottom right. The far away ones have a strange bug in that it displays the minus sign twice and reflects a seemingly nonexistent deficit. Not sure how to clean that one up.
Using PitBull4 im trying to get the level and classification elite, rare, boss, elite-rare to show with difficulty color for the level and yellow for elite abbreviated to "E", silver for rare or elite-rare abbreviated to "R" and then red for boss abbreviated to "B".
Example: 90B
This is the code I started I was at least trying to get the level and classification to show up but I couldn't get it working.
local dr,dg,db, = DifficultyColor(unit)
local classification = Classification(unit)
return " |cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r", dr,dg,db, Level(unit), dr,dg,db, Classification(unit)
I have a second question. Can you alter the code below to show the leader by coloring the name of the person who has it yellow otherwise the default color white. As well as add a "$" to the name of the person who has master loot need this for player, party, raid.
Example: TEEMO$
if (string.len(Name(unit)) > 20) then
TruncName = (string.sub(string.upper(Name(unit)), 1, 20) .. "...")
else
TruncName = string.upper(Name(unit))
end
return '%s %s%s%s',TruncName,Angle(AFK(unit) or DND(unit))
local r, g, b = DifficultyColor(unit)
local c = UnitClassification(unit)
if c == "worldboss" then
return "|cff%02x%02x%02x%s|r%s", r, g, b, Level(unit), "|cffff0000B|r"
elseif c == "rareelite" then
return "|cff%02x%02x%02x%s|r%s", r, g, b, Level(unit), "|cffffcc00R|r"
elseif c == "rare" then
return "|cff%02x%02x%02x%s|r%s", r, g, b, Level(unit), "|cff999999R|r"
elseif c == "elite" then
return "|cff%02x%02x%02x%s|r%s", r, g, b, Level(unit), "|cffffcc00E|r"
else
return "|cff%02x%02x%02x%s|r", r, g, b, Level(unit)
end
This will probably work for your second request:
local name = Name(unit)
if strlen(name) > 20 then
name = strsub(name, 1, 20) .. "..."
end
local _, partyMaster, raidMaster = GetLootMethod()
if (raidMaster and UnitIsUnit(unit, "raid"..raidMaster)) or (partyMaster and UnitIsUnit(unit, "party"..partyMaster)) or (partyMaster == 0 and UnitIsUnit(unit, "player")) then
name = name.."$ "
end
if UnitIsPartyLeader(unit) or UnitIsRaidLeader(unit) then
name = "|cffffcc00"..name.."|r"
end
return "%s %s%s%s", name, Angle(AFK(unit) or DND(unit))
If LuaTexts includes MasterLooter and/or Leader functions then you can simplify that, but I don't use it myself and am too lazy to go read through the code to find out.
Phanx big thanks for helping and for a fast response! The first code worked perfectly. I am still learning Lua so any help is appreciated. The second code returned a blank, no error and no text at all. Thanks again for all your help your amazing and have made my day. I will work on the second code in my spare time. If you have any other ideas about this code please feel free. Also if you have any good info/tuts for this stuff, that would be awesome.
Awesome, thanks again. What was the typo? How do you turn error on? Also on the first code I noticed when I leveled, the level wouldn't update on the player frame unless I did a reload of some sort, it worked fine updating the target without a reload.
I ran into another roadblock on my ui, maybe you can help. If you know kgpanels, I was wondering if there was a way to create 2 panels, one to act as the background and the other to act as the alert. I need both panels to show player, and/or my targets pvp indicator/flag. Have it class color if player or friendly and hostile color if enemy, and only show if flagged for pvp. I found a ton of stuff online but not was quiet what I was looking for and my attempts to hack something together are failing me.
I don't remember what the typo was, but if you copy the code that's there now, it should be fine.
You turn errors on under Interface Options > Help > Display Lua Errors, or you can install the addon BugSack which will let you store errors to deal with at a more convenient time, and will catch errors that occur during the login screen.
I'm happy to help you with kgPanels questions, but not in the LuaTexts thread. Post a new thread in the Addon HELP! forum with those questions.
Is it possible to change the text size based on criterias?
What I'd like to do is if the a name is longer then 14 characters it should decrease the text size (not truncate the text, but shrink it).
Outline()
local name = Name(unit)
local r,g,b = ClassColor(unit)
local val = strsub(1,6)
if not UnitIsConnected(unit) then
val="Offline"
elseif UnitIsAFK(unit) then
val="AFK"
end
if #name > 14 then
[B]--( Shrink the text size if this is true! )[/B]
return '|cff%02x%02x%02x%s|r %s',r,g,b,string.sub(name,1,22),val
else
return '|cff%02x%02x%02x%s|r %s',r,g,b,name,val
end
Not possible. LuaTexts can only control the text displayed by the fontstring. The output of your LuaTexts tag is passed to the fontstring's SetText method. In order to change the size of the fontstring, you need to use its SetFont method. You would need to either write a PitBull module, or ask the authors of PitBull to add this feature, or modify PitBull's code yourself to implement this feature.
I haven't been able to figure out how to convert the following DogTagTexts to Lua Text:
[(if MP > 0 then
MP:VeryShort
end)] [Name] [Level:DifficultyColor]
[(~IsMaxHP ? ~Dead ? Outline PercentHP:HPColor)]
So far I've been using:
Outline()
local cur, max = HP(unit), MaxHP(unit)
local r,g,b = HPColor(cur, max)
if Percent(HP(unit),MaxHP(unit)) < 100 then
return "|cff%02x%02x%02x%s%%|r",r,g,b,Percent(cur,max)
end
to replace the 2nd DogTag, but I'd like it to hide when the unit is dead and hide the "%" symbol at all times. Thank you in advance for any assistance.
if UnitIsDead(unit) then
return
end
local cur, max = HP(unit), MaxHP(unit)
if cur == max then
local r, g, b = HPColor(cur, max)
return "|cff%02x%02x%02x%s|r", r, g, b, Percent(cur, max)
end
No idea what the Outline() call at the top is supposed to do since it doesn't return any value, but if it has some effect feel free to put it back in.
local power = Power(unit)
local dr, dg, db = DifficultyColor(unit)
return "%s |cff%02x%02x%02x%s%s|r %s",
Name(unit), dr, dg, db, Level(unit),
Classification(unit) and "+" or "",
power > 0 and VeryShort(power) or ""
Yes, and it appears to be working properly after I changed "VeryShort(power)" to "VeryShort(power,true)".
The text is not fully aligning to the left after the power text is hidden (http://i.imgur.com/dmo3hEM.jpg), though. Is there any way to make the lua text adjust its alignment to the left, when temporarily hiding the power text?
Move the space from the base string to the inserted part for power:
local power = Power(unit)
local dr, dg, db = DifficultyColor(unit)
return "%s |cff%02x%02x%02x%s%s|r%s",
Name(unit), dr, dg, db, Level(unit),
Classification(unit) and "+" or "",
power > 0 and (" " .. VeryShort(power, true)) or ""
Edit: joined an AV that was in progress and saw this odd behavior:
http://img710.imageshack.us/img710/8451/raidframes.jpg
As you can see, the health display is behaving properly for players nearby, such as the shaman in the bottom right. The far away ones have a strange bug in that it displays the minus sign twice and reflects a seemingly nonexistent deficit. Not sure how to clean that one up.
Example: 90B
This is the code I started I was at least trying to get the level and classification to show up but I couldn't get it working.
I have a second question. Can you alter the code below to show the leader by coloring the name of the person who has it yellow otherwise the default color white. As well as add a "$" to the name of the person who has master loot need this for player, party, raid.
Example: TEEMO$
Thanks for any help :)
This will probably work for your second request:
If LuaTexts includes MasterLooter and/or Leader functions then you can simplify that, but I don't use it myself and am too lazy to go read through the code to find out.
I ran into another roadblock on my ui, maybe you can help. If you know kgpanels, I was wondering if there was a way to create 2 panels, one to act as the background and the other to act as the alert. I need both panels to show player, and/or my targets pvp indicator/flag. Have it class color if player or friendly and hostile color if enemy, and only show if flagged for pvp. I found a ton of stuff online but not was quiet what I was looking for and my attempts to hack something together are failing me.
Thanks again.
You turn errors on under Interface Options > Help > Display Lua Errors, or you can install the addon BugSack which will let you store errors to deal with at a more convenient time, and will catch errors that occur during the login screen.
I'm happy to help you with kgPanels questions, but not in the LuaTexts thread. Post a new thread in the Addon HELP! forum with those questions.
What I'd like to do is if the a name is longer then 14 characters it should decrease the text size (not truncate the text, but shrink it).
I'm using PitBull4 if that matters.
So far I've been using:
to replace the 2nd DogTag, but I'd like it to hide when the unit is dead and hide the "%" symbol at all times. Thank you in advance for any assistance.
No idea what the Outline() call at the top is supposed to do since it doesn't return any value, but if it has some effect feel free to put it back in.
I have my Unit Frame set to display: power, name, then level, on one line, while hiding the value for power if it's 0.
The text is not fully aligning to the left after the power text is hidden (http://i.imgur.com/dmo3hEM.jpg), though. Is there any way to make the lua text adjust its alignment to the left, when temporarily hiding the power text?