Text that shows a players class and level (in the format of "[80] Death Knight") and colors the level by difficulty and class by it's corresponding class-color OR if it's a mob- displays whether it is a "Boss, "Elite", "Rare" or a "Rare-Elite" as well as having its level colored by difficulty and the elite/rare bit, well, default (in the format of "[81] Elite") and if it is a mob that isn't rare or elite just displays its level and colors it by difficulty (format of "[80]")
Both of these versions should work. The first is simpler, but will look funny if the text is right-aligned. On the other hand the second has some extra complications but will right-align properly, if needed.
local lvl=Level(unit)
local dr,dg,db=DifficultyColor(unit)
if UnitIsPlayer(unit) then
local class=Class(unit)
local cr,cg,cb=ClassColor(unit)
return "|cff%02x%02x%02x[%s]|r |cff%02x%02x%02x%s|r",dr,dg,db,lvl,cr,cg,cb,class
else
local class=Classification(unit)
return "|cff%02x%02x%02x[%s] %s",dr,dg,db,lvl,class or ''
end
local lvl=Level(unit)
local dr,dg,db=DifficultyColor(unit)
if UnitIsPlayer(unit) then
local class=Class(unit)
local cr,cg,cb=ClassColor(unit)
return "|cff%02x%02x%02x[%s]|r |cff%02x%02x%02x%s|r",dr,dg,db,lvl,cr,cg,cb,class
else
local class=Classification(unit)
if class then
return "|cff%02x%02x%02x[%s] %s",dr,dg,db,lvl,class
else
return "|cff%02x%02x%02x[%s] %s",dr,dg,db,lvl
end
Lastly, How would i go about getting health% (default LUA text) just showing "Dead" instead of Dead xx
if UnitIsDead(unit) then
return Dead
else
....
end
The .... is the standard tag, I am not at a WoW computer so I can't look at the exact code to make a cleaner version, but this should work.
EDIT: I forgot to add that the return from each LuaText is fed through Lua's string.format function, so all of the standard formatting patterns apply, which is how we get the colours from PowerColor() into the right format for the escape sequence.
Actually it's fed to SetFormattedText which isn't implemented in Lua but behaves the same way as string.format. It's a minor distinction but one that's somewhat important with respect to garbage.
Both of these versions should work. The first is simpler, but will look funny if the text is right-aligned. On the other hand the second has some extra complications but will right-align properly, if needed.
local lvl=Level(unit)
local dr,dg,db=DifficultyColor(unit)
if UnitIsPlayer(unit) then
local class=Class(unit)
local cr,cg,cb=ClassColor(unit)
return "|cff%02x%02x%02x[%s]|r
"|cff%02x%02x%02x%s|r",dr,dg,db,lvl,cr,cg,cb,class
else
local class=Classification(unit)
return "|cff%02x%02x%02x[%s] %s",dr,dg,db,lvl,class or ''
end
local lvl=Level(unit)
local dr,dg,db=DifficultyColor(unit)
if UnitIsPlayer(unit) then
local class=Class(unit)
local cr,cg,cb=ClassColor(unit)
return "|cff%02x%02x%02x[%s]|r
"|cff%02x%02x%02x%s|r",dr,dg,db,lvl,cr,cg,cb,class
else
local class=Classification(unit)
if class then
return "|cff%02x%02x%02x[%s] %s",dr,dg,db,lvl,class
else
return "|cff%02x%02x%02x[%s] %s",dr,dg,db,lvl
end
Thank you for the code, however both of them are giving me a LUA error in WoW.
I'm sure it's just a simple mistake; however, I mean it when I say I have NO idea when it comes to LUA :(
I made a minor change to fix an error that I have no clue how I made. If it still doesn't work try using Bugsack or something to give me the first few lines of the error.
I need your help. I know nothing about Lua code, and know a little about dogtags but I can't see a way to make what I'm trying to via dogtags so I was wondering if anybody could tell me what should I write to make it work via lua.
I want to show in the cast bar the Classification, Level and Name of the mob/player name but if casting or channeling any spell then show the spell's name and duration.
At least a little clue.
Thanks a lot.
Edit:
I'm not really sure how I achieved it but I took the standard lua codes that comes with pitbull for name, class+level and cast and mixed them and I made it work X___D
This is what I wrote (copied, mixed, pasted indeed :P):
local dr,dg,db = DifficultyColor(unit)
local r,g,b = ClassColor(unit)
local cast_data = CastData(unit)
if cast_data then
local spell,stop_message,target = cast_data.spell,cast_data.stop_message,cast_data.target
local stop_time,stop_duration = cast_data.stop_time
if stop_time then
stop_duration = GetTime() - stop_time
end
Alpha(-(stop_duration or 0) + 1)
if stop_message then
return stop_message
elseif target then
return "%s (%s)",spell,target
else
return spell
end
else
return '%s%s |cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r %s%s%s',Classification(unit) and '+' or '',ShortRace(unit) or '',dr,dg,db,Level(unit),r,g,b,Name(unit),Angle(AFK(unit) or DND(unit))
end
Now, is there a way to make the name tag to have a bigger font size or in capital letters?
Thanks
Couple of weeks ago someone posted the following code on EJ to show the range to a unit:
local rc = LibStub("LibRangeCheck-2.0")
local minRange, maxRange = rc:getRange(unit)
UpdateIn(1.0)
return "|cff404040%s", tostring(maxRange or "oor")
After patching to the latest Version of PB (beta5) this gives the following error:
[2009/09/16 00:42:40-3431-x1]: <string>:"PitBull4_LuaTexts:Target:range":1: Cannot find a library instance of "LibRangeCheck-2.0".
PitBull4_LuaTexts-v4.0.0-beta5\LuaTexts.lua:1153: in function `AddFontString'
PitBull4-v4.0.0-beta5\ModuleHandling\TextProviderModule.lua:118: in function `UpdateFrame'
PitBull4-v4.0.0-beta5\ModuleHandling\Module.lua:319: in function `Update'
PitBull4-v4.0.0-beta5\UnitFrame.lua:636: in function `Update'
PitBull4-v4.0.0-beta5\UnitFrame.lua:662: in function `UpdateGUID'
PitBull4-v4.0.0-beta5\Main.lua:1330: in function `CheckGUIDForUnitID'
PitBull4-v4.0.0-beta5\Main.lua:1341: in function `?'
CallbackHandler-1.0-3:146: in function <non>
<string>:"safecall Dispatcher[1]":4: in function <string>
<in>: ?
<string>:"safecall Dispatcher[1]":13: in function `?'
CallbackHandler-1.0-3:91: in function `Fire'
AceEvent-3.0-3 (Bagnon):119: in function <ace>
<in>: in function `TargetUnit'
Interface\FrameXML\SecureTemplates.lua:379: in function `handler':
Interface\FrameXML\SecureTemplates.lua:487: in function `SecureActionButton_OnClick':
Interface\FrameXML\SecureTemplates.lua:528: in function <Interface>:
I suppose this comes from the changes to range fading introduced in beta5? Is there a way to make this code work again, or maybe a more ellegant way of coding this?
You mean copying the LibRangeCheck-2.0 into the Interface folder?
I've done it like this since I started using this code and also after patching to beta5, I didn't change anything else. Afaik LibRangeCheck-2.0 was never implemented in PB4 libs package (at least not obviously) , you always have to install it seperately to get this code to work.
Problem is solved if the LibRange is copied into the Libs Folder of PB4 and one includes the lib manually by editing the libs.xml. Not very comfortable but it works. Anyone know why this has changed in contrast to the previous version (<beta5)?
Problem is solved if the LibRange is copied into the Libs Folder of PB4 and one includes the lib manually by editing the libs.xml. Not very comfortable but it works. Anyone know why this has changed in contrast to the previous version (<beta5)?
Install it just like you would any other addon and *NOT* insert the library as an embed.
PitBull4 has never and will probably never embed that library. Installing it as you have will break every single time you update PitBull4. Installing it like I just said above should never break.
Installing it as you have will break every single time you update PitBull4.
Actually, that's what I'm afraid of. ;)
You probably had some other addon that had the library embedded into it or you installed it like you just did.
As already said, before I updated PB to beta5 I installed LibRangeCheck excatly like I would do it with any other addon. There is also no other addon embedding the Lib. You can try the code with your current PB version and tell me if it's working the way you meant it to work.
I did some further testing and downgraded to older versions and found out that beta5 is not the first version that stops the code from working. So what I did:
1.) Copy the LibRangeCheck into the Interface folder and make sure no other addon is using LibRangeCheck.
2.) Tested the code with the newest version of PB4 => {err} (broken)
3.) Installed the PB4 version I used before (beta3-31, it's very old I know ;) ) => it works :o
4.) Tested some other versions and found out that version beta3-50-g83e4d94 is the last version that works with the code. The code is broken when I update to beta3-65-gda1fb14. That's the first version with seperate Pitbull4-xyz Folders for each module.
As already said, before I updated PB to beta5 I installed LibRangeCheck excatly like I would do it with any other addon. There is also no other addon embedding the Lib. You can try the code with your current PB version and tell me if it's working the way you meant it to work.
I didn't write the code so I don't intend it to work or not work.
After looking at the code and thinking about it more it's never going to work reliably as written. The change to LoadOnDemand stuff probably shifted around the load order on your particular system. PitBull4 and LuaTexts is loading before LibRangeCheck.
Something like this should work. It won't throw errors if libRangeCheck isn't loaded and will try and load it if it isn't. It also avoids repeated calls to LibStub.
if not libRangeCheck then
LoadAddOn("LibRangeCheck-2.0")
libRangeCheck = LibStub("LibRangeCheck-2.0")
end
if libRangeCheck then
local minRange, maxRange = libRangeCheck:getRange(unit)
UpdateIn(1.0)
return "|cff404040%s", tostring(maxRange or "oor")
end
Thanks very much, but this is not exactly what I want. Maybe I express myself badly (sorry, my English is poor). What this does is eliminate the X first characters of the name, if X=3 and the name is "Dorthian" it will return "thian". What I want is if the name has more than 20 characters then shorten it and place a "..." at the end.
Thanks very much, but this is not exactly what I want. Maybe I express myself badly (sorry, my English is poor). What this does is eliminate the X first characters of the name, if X=3 and the name is "Dorthian" it will return "thian". What I want is if the name has more than 20 characters then shorten it and place a "..." at the end.
No, its actually my fault for trying to code from memory, I'm sorry.
string.sub(string.upper(Name(unit)), 1, 20)
That should make everything upper case and show only the first 20 characters of a name. Adding a "..." at the end if it is truncated would be a bit more complicated, and I'm not sure how to go about that easily right now... but at least I'm closer to what you want than before.
I am sure there is a better way[PHP]
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))[/PHP]
I have another problem with luatexts. I want the following information for my pally to be shown in my raidframes.
1.) Beacon duration just for my beacon
2.) Sacred shield duration for my Shield
3.) Sacred Shield w/o duration for other players
For 1) and 2) I've tried to merge some of the code from this thread (3) should be no problem if 1) and 2) are working):
local i = 1
local beacon,sacred = false,false
while true do
local name,_,_,_,_,_,expires,caster = UnitAura(unit,i,"HELPFUL")
if not name then
break
elseif name == "Beacon of Light" and caster == "player" then
beacon = true
local beaconexp = expires - GetTime()
elseif name == "Sacred Shield" and caster == "player" then
sacred = true
local sacredexp = expires - GetTime()
end
i = i + 1
end
return "%1.0f %1.0f",beacon and beaconexp,sacred and sacredexp'
This code gives me "NIL" if these buffs are up. Is there some way to make this code work similar to the "icon_count-code", if you want to add more buffs with durations? Something like this:
...
elseif name == "Beacon of Light" and caster == "player" then
local exp = expires - GetTime()
icon_count=icon_count+1
icons[icon_count] = "sacred"
dura[icon_count] = exp
...
if icon_count > 0 then
local format = string.rep("%s%s|r",icon_count,icon_count)
return format,unpack(icons),unpack(dura)
end
The string.rep part is false I think, but I have no clue how to expand the code to store the icons and the duration and use them in the return expression.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Voted. Thanks!
The .... is the standard tag, I am not at a WoW computer so I can't look at the exact code to make a cleaner version, but this should work.
Actually it's fed to SetFormattedText which isn't implemented in Lua but behaves the same way as string.format. It's a minor distinction but one that's somewhat important with respect to garbage.
Thank you for the code, however both of them are giving me a LUA error in WoW.
I'm sure it's just a simple mistake; however, I mean it when I say I have NO idea when it comes to LUA :(
Cheers, Red.
I need your help. I know nothing about Lua code, and know a little about dogtags but I can't see a way to make what I'm trying to via dogtags so I was wondering if anybody could tell me what should I write to make it work via lua.
I want to show in the cast bar the Classification, Level and Name of the mob/player name but if casting or channeling any spell then show the spell's name and duration.
At least a little clue.
Thanks a lot.
Edit:
I'm not really sure how I achieved it but I took the standard lua codes that comes with pitbull for name, class+level and cast and mixed them and I made it work X___D
This is what I wrote (copied, mixed, pasted indeed :P):
Now, is there a way to make the name tag to have a bigger font size or in capital letters?
Thanks
After patching to the latest Version of PB (beta5) this gives the following error:
I suppose this comes from the changes to range fading introduced in beta5? Is there a way to make this code work again, or maybe a more ellegant way of coding this?
I've done it like this since I started using this code and also after patching to beta5, I didn't change anything else. Afaik LibRangeCheck-2.0 was never implemented in PB4 libs package (at least not obviously) , you always have to install it seperately to get this code to work.
Nothing we did changed this. You probably had some other addon that had the library embedded into it or you installed it like you just did. You really should just go get the file hosted here: http://wow.curse.com/downloads/wow-addons/details/librangecheck-2-0.aspx
Install it just like you would any other addon and *NOT* insert the library as an embed.
PitBull4 has never and will probably never embed that library. Installing it as you have will break every single time you update PitBull4. Installing it like I just said above should never break.
As already said, before I updated PB to beta5 I installed LibRangeCheck excatly like I would do it with any other addon. There is also no other addon embedding the Lib. You can try the code with your current PB version and tell me if it's working the way you meant it to work.
I did some further testing and downgraded to older versions and found out that beta5 is not the first version that stops the code from working. So what I did:
1.) Copy the LibRangeCheck into the Interface folder and make sure no other addon is using LibRangeCheck.
2.) Tested the code with the newest version of PB4 => {err} (broken)
3.) Installed the PB4 version I used before (beta3-31, it's very old I know ;) ) => it works :o
4.) Tested some other versions and found out that version beta3-50-g83e4d94 is the last version that works with the code. The code is broken when I update to beta3-65-gda1fb14. That's the first version with seperate Pitbull4-xyz Folders for each module.
I didn't write the code so I don't intend it to work or not work.
After looking at the code and thinking about it more it's never going to work reliably as written. The change to LoadOnDemand stuff probably shifted around the load order on your particular system. PitBull4 and LuaTexts is loading before LibRangeCheck.
Something like this should work. It won't throw errors if libRangeCheck isn't loaded and will try and load it if it isn't. It also avoids repeated calls to LibStub.
to make the name be shown in uppercase letters and truncate it if it's longer than 20 characters?
Thanks
Thanks very much, but this is not exactly what I want. Maybe I express myself badly (sorry, my English is poor). What this does is eliminate the X first characters of the name, if X=3 and the name is "Dorthian" it will return "thian". What I want is if the name has more than 20 characters then shorten it and place a "..." at the end.
No, its actually my fault for trying to code from memory, I'm sorry.
That should make everything upper case and show only the first 20 characters of a name. Adding a "..." at the end if it is truncated would be a bit more complicated, and I'm not sure how to go about that easily right now... but at least I'm closer to what you want than before.
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))[/PHP]
1.) Beacon duration just for my beacon
2.) Sacred shield duration for my Shield
3.) Sacred Shield w/o duration for other players
For 1) and 2) I've tried to merge some of the code from this thread (3) should be no problem if 1) and 2) are working):
This code gives me "NIL" if these buffs are up. Is there some way to make this code work similar to the "icon_count-code", if you want to add more buffs with durations? Something like this:
The string.rep part is false I think, but I have no clue how to expand the code to store the icons and the duration and use them in the return expression.