I just added a %s within the quotes (creating another string output) and "s or '' ", at the end of each line. This won't give you the proper output for a lot of afk/dnd cases, because Status doesn't really return those very well.
local s = Status(unit)
local dr,dg,db = DifficultyColor(unit)
local lvl = Level(unit)
local name = Name(unit)
if UnitIsPlayer(unit) then
local cr,cg,cb = ClassColor(unit)
local form = DruidForm(unit)
if form then
form = strsub(form,1,1)
return "|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s (%s)|r %s" ,dr,dg,db,lvl,cr,cg,cb,name,form,s or ''
else
return "|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r %s" ,dr,dg,db,lvl,cr,cg,cb,name,s or ''
end
else
local classif = Classification(unit)
if classif then
return "|cff%02x%02x%02x%s %s|r %s %s" ,dr,dg,db,lvl,classif,name,s or ''
else
return "|cff%02x%02x%02x%s|r %s %s" ,dr,dg,db,lvl,name,s or ''
end
end
The other option is to just have to tags sitting right next to eachother (you can place two texts in the same location, and just tell them the order.
local s = Status(unit)
if s then
return s
elseif UnitIsAFK(unit) then
return '%s',AFK(unit) or 'AFK'
elseif UnitIsDND(unit) then
return '%s',DND(unit) or 'DND'
end
The reason for these complex AFK and DND checks is that non-party members will not have good returns to AFK and DND via AFK() or DND().
The second thing I wrote will show the time, if the data is available. If the data isn't it will still say AFK or DND if appropriate.
Status() will not return AFK or DND if it cannot ascertain the time. I don't like that, since not all units will give a time for you, but I still want to know if they are AFK or DND.
I edited the tag to something closer to what I use (I do AFK/DND status separately from other status)
I don't use Status anywhere, and that was my problem, I was under the impression that it showed AFK/DND times if they were available, but that is actually AFK() and DND().
Hello there,
i've got a short question which might been asked beforehand, but 43 pages are a bit long to read though (yes, i used the search function :) )
Is there a way to display incoming heal as a text element within Pitbull4-Frames using luatext?
The DogTag help does not give a function to display this, and I'm far behind the point to bring a luatext-function providing this feature.
Though PB4 is able to show incoming heal using a bar (-> visual heal), the translation to give this information by text should be possible.
And have the formatting tat would normally happen in the Short() function happen upstream in compiled code instead of in Lua (which avoids garbage creationn). If you pass true as the 2nd parameter it tells Short() or VeryShort to do the formatting itself for you. This produces garbage.
Shefki, can you add this information to the LuaTexts documentation page please? The current description does not explain why I would want to do it one way or the other.
Since the thing i am looking for is based on mouseover i tried searching the thread for mouseover and ended up with two replies. This didn't answer anything for me (since i suck at this). Having said that , i hope i am not asking an already answered question.
Could someone help me with a health Luatext
I would like it to show nothing at all if full health until mouseover , then show only current health.
When not full health , show health deficiency , then on mouseover , show only current/max health.
Thanks in advance guys. (I really think there should be some gathering place , like a wiki or something , where people can add their own pieces of luatext , and other stuff maybe.
I would like it to show nothing at all if full health until mouseover , then show only current health.
When not full health , show health deficiency , then on mouseover , show only current/max health.
local cur,max=HP(unit),MaxHP(unit)
local miss=max-cur
if miss==0 then
if IsMouseOver() then
return cur
end
else
if IsMouseOver() then
return "%s/%s",cur,max
else
return "-%s",miss
end
end
@panga: try this LuaText out. I didn't test it but it's heavily based on my own (which includes HPColor and shows slightly different information)
[php]local cur = HP(unit)
local max = MaxHP(unit)
if IsMouseOver() then
if cur ~= max then
return "%s | %s", cur, max
else
return "%s", cur
end
else
if cur ~= max then
return "-%s", max - cur
end
end[/php]
You can see the basic structure here anyhow, should be simple to adjust to your taste from this point.
EDIT: ROFL, obviously sfan and I tend to surf these forums at exactly the same time, hehe.
Hey guys, I'm sure this is really simple and I'm a total UI nub, but I was wondering if someone could give me the method of changing the Health/mana text from saying for example "1k" instead of "988"? I'm pretty happy with my UI and in my noobishness it's taken me ages, but this is just one little thing that bugs me!
This is mostly an FYI. You probably won't see these changes for a while. I haven't written the code for them but the changes are pretty well laid out in my mind.
As things exist right now events are configured globally as to what units they will trigger. If you need to add a new event for your text you have to go to the modules section and add it, then come back to your actual text and select it from the dropdown box. Additionally, having the events in the dropdown box puts them out of band and means a lot of the times when they get shared on forums people forget to mention the events.
LuaTexts was originally designed as a quick drop replacement for DogTagTexts for debugging purposes and grew from there. My primary goal when I decided to make it something more than just a debugging tool was to ensure that all the default tags could be implemented. Which we have since then far surpassed.
Unfortunately, with the above in mind some things didn't occur to me at the time of writing it. In particular showing info about another unit than the frame that the text is attached to. These sorts of requests have come up where some things that could be done with DogTagTexts could not be done with LuaTexts.
As a result the following changes are going to be made to LuaTexts.
Setting the events to trigger updates for the text will be done in the code. This will be achieved with a call to a UpdateOn() function which will take one event name and a list of units to update for.
UpdateOn() if passed no units it update if the first argument of the event is the same as the unit id for the frame the text is attached to. This is the Unit checkbox in the current configuration.
UpdateOn() can also take some special strings that aren't really unit ids such as "_all" to ignore the arguments in the event and trigger regardless. This is the All option in the current configuration.
UpdateOn() can also take a function as the final parameter. Which will receive all the events arguments and will return true if the event should trigger an update and false if it should not. Care should be taken when using this to avoid creating unnecessary closures. Examples will be provided to show how to do this without hurting performance too much when it is necessary. Currently this is not possible to do and there are events such as COMBAT_LOG_EVENT_UNFILTERED that would not be possible to trigger off if in the current design.
The existing GUI configuration of events under Modules and the drop down box to choose events will be REMOVED. Loading a profile once this code is implemented will result in the addon writing the appropriate UpdateOn() calls at the top of your code for you to implement what is selected in the GUI. (This also means that it will not be possible to rollback to a previous version without this new design)
The existing implicit update systems will be implemented as private events. For example using Power(unit) flags your text to be updated quickly if the unit is the player or the player's pet. This behavior will continue to exist. However, the flagging of this will be implmented as an UpdateOn() call with a event name such as "_FastPower" with identical arguments as we have with Blizzard generated events.
A new public facing API call will be available to request that a text be updated will be added. This will allow the use of complicated modules requiring callback support.
A new public facing API call will be available to generate private events. Allowing complicated functionality to be implemented as separate addons and allowing other modules within Pitbull4 to provide trigger text updates. Essentially, this opens up the possibility of expansions of the convenience functions for libraries and other things that I'm unwilling to put in the baseline system.
Ultimately, this should improve the ability to share prewritten texts as they will be entirely inclusive of everything needed for them to work. It will unify the currently separate update systems (Blizzard events and privately generated implicit events). It should eliminate the few things that are difficult or impossible to do with LuaTexts at current.
If you have a text idea that you don't see how you can make it work with the above system I'd very much like to hear from you.
Edit: I'm also considering changing the default behavior of the Short() and VeryShort() calls without the boolean. Currently the boolean is required to get those functions to do the formatting for you. Since I'll be rewriting the code and will have an easy way to detect any unconverted code I may clean up this wart on the API.
The one downside of all this is texts currently floating around may of course become obsolete and out of date. However, these will usually be very easy to notice due to the lack of an UpdateOn() call.
I hope to help alleviate this by coming up with a page of commonly requested codes based on the postings in this thread and the one over on elitistjerks. That I will be bringing up to date along with the addon.
One thing I would like to see in a future revision of LuaTexts is the ability to add custom presets. Sometimes I want to use the same text in multiple frame layouts. Needing to copy-and-paste then edit both of them when I decide to change something is a pain.
ninja-edit: Also, I think moving to this "UpdateOn" design for events is a mistake without some kind of helper built in to the configuration UI. Currently, you can look at the list of events, and they are self-explanatory to at least some degree, so even an amateur programmer can kind of figure out which ones he wants to use. With declarative update settings in the Lua code itself, you'd need some kind of drop-down "insert update" button or inline documentation to achieve the same degree of discoverability.
Shefki, will this allow the use of external librairies such as LibTalentQuery that generate a callback? My guess is yes, but what you wrote above is a little above my level of expertise.
One thing I would like to see in a future revision of LuaTexts is the ability to add custom presets. Sometimes I want to use the same text in multiple frame layouts. Needing to copy-and-paste then edit both of them when I decide to change something is a pain.
As far as the Event stuff, I think it would be great if the correct Events were registered automatically. Keep the UpdateOn() call available though for advanced or quirky texts. You can tell just by looking at the API calls which events you'll need really, with very few exceptions. I actually like Events the way they are now, but I can see how moving away from a separate widget is a good idea. I just think if you are doing this to make it simpler, then there's benefit in taking the idea to it's conclusion.
I can't get my head around a few things in LUA, specifically..
How would I go about getting class-colored names BUT instead of < AFK (x.xx)> just " AFK" or " DND" in white
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]")
Also, how do I add the users power-color to this:
local max = MaxPower(unit)
if max > 0 then
return (Power(unit))
end
^--(All I want this to do is show me how much current power the unit has and its color, there is probably an easier way to code this >_<)
Lastly, How would i go about getting health% (default LUA text) just showing "Dead" instead of Dead x:xx
The thing with LuaTexts is you sort of have to combine a few WoW secrets to get the most out of them. :) For example, in order to display coloured text, you need to use an escape sequence:
"|caarrggbb<text to be coloured>|r"
An example of the string "Howdie" in blue would look like this:
"|cff0000ffHowdie|r"
Your coloured Power text will look something like:
[php]local max = MaxPower(unit)
local cur = Power(unit)
if max > 0 then
local _, types = UnitPowerType(unit)
local r, g, b = PowerColor(types)
return "|cff%02x%02x%02x%s|r", r, g, b, cur
end[/php]
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.
And I don't care about target/focus/etc, I just want it for party/raid frames
Status() will not return AFK or DND if it cannot ascertain the time. I don't like that, since not all units will give a time for you, but I still want to know if they are AFK or DND.
I don't use Status anywhere, and that was my problem, I was under the impression that it showed AFK/DND times if they were available, but that is actually AFK() and DND().
i've got a short question which might been asked beforehand, but 43 pages are a bit long to read though (yes, i used the search function :) )
Is there a way to display incoming heal as a text element within Pitbull4-Frames using luatext?
The DogTag help does not give a function to display this, and I'm far behind the point to bring a luatext-function providing this feature.
Though PB4 is able to show incoming heal using a bar (-> visual heal), the translation to give this information by text should be possible.
Shefki, can you add this information to the LuaTexts documentation page please? The current description does not explain why I would want to do it one way or the other.
Could someone help me with a health Luatext
I would like it to show nothing at all if full health until mouseover , then show only current health.
When not full health , show health deficiency , then on mouseover , show only current/max health.
Thanks in advance guys. (I really think there should be some gathering place , like a wiki or something , where people can add their own pieces of luatext , and other stuff maybe.
[php]local cur = HP(unit)
local max = MaxHP(unit)
if IsMouseOver() then
if cur ~= max then
return "%s | %s", cur, max
else
return "%s", cur
end
else
if cur ~= max then
return "-%s", max - cur
end
end[/php]
You can see the basic structure here anyhow, should be simple to adjust to your taste from this point.
EDIT: ROFL, obviously sfan and I tend to surf these forums at exactly the same time, hehe.
Apologies for the fail, and thanks in advance!
As things exist right now events are configured globally as to what units they will trigger. If you need to add a new event for your text you have to go to the modules section and add it, then come back to your actual text and select it from the dropdown box. Additionally, having the events in the dropdown box puts them out of band and means a lot of the times when they get shared on forums people forget to mention the events.
LuaTexts was originally designed as a quick drop replacement for DogTagTexts for debugging purposes and grew from there. My primary goal when I decided to make it something more than just a debugging tool was to ensure that all the default tags could be implemented. Which we have since then far surpassed.
Unfortunately, with the above in mind some things didn't occur to me at the time of writing it. In particular showing info about another unit than the frame that the text is attached to. These sorts of requests have come up where some things that could be done with DogTagTexts could not be done with LuaTexts.
As a result the following changes are going to be made to LuaTexts.
If you have a text idea that you don't see how you can make it work with the above system I'd very much like to hear from you.
Edit: I'm also considering changing the default behavior of the Short() and VeryShort() calls without the boolean. Currently the boolean is required to get those functions to do the formatting for you. Since I'll be rewriting the code and will have an easy way to detect any unconverted code I may clean up this wart on the API.
The one downside of all this is texts currently floating around may of course become obsolete and out of date. However, these will usually be very easy to notice due to the lack of an UpdateOn() call.
I hope to help alleviate this by coming up with a page of commonly requested codes based on the postings in this thread and the one over on elitistjerks. That I will be bringing up to date along with the addon.
ninja-edit: Also, I think moving to this "UpdateOn" design for events is a mistake without some kind of helper built in to the configuration UI. Currently, you can look at the list of events, and they are self-explanatory to at least some degree, so even an amateur programmer can kind of figure out which ones he wants to use. With declarative update settings in the Lua code itself, you'd need some kind of drop-down "insert update" button or inline documentation to achieve the same degree of discoverability.
There's already a ticket for this: 431 Code section to reuse LuaTexts or DogTags. It's already been set to "Accepted", but it's fairly low-priority at the moment. Go vote!
As far as the Event stuff, I think it would be great if the correct Events were registered automatically. Keep the UpdateOn() call available though for advanced or quirky texts. You can tell just by looking at the API calls which events you'll need really, with very few exceptions. I actually like Events the way they are now, but I can see how moving away from a separate widget is a good idea. I just think if you are doing this to make it simpler, then there's benefit in taking the idea to it's conclusion.
How would I go about getting class-colored names BUT instead of < AFK (x.xx)> just " AFK" or " DND" in white
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]")
Also, how do I add the users power-color to this:
local max = MaxPower(unit)
if max > 0 then
return (Power(unit))
end
^--(All I want this to do is show me how much current power the unit has and its color, there is probably an easier way to code this >_<)
Lastly, How would i go about getting health% (default LUA text) just showing "Dead" instead of Dead x:xx
Any help would be appreciated :~D, Red.
The thing with LuaTexts is you sort of have to combine a few WoW secrets to get the most out of them. :) For example, in order to display coloured text, you need to use an escape sequence:
An example of the string "Howdie" in blue would look like this:
Your coloured Power text will look something like:
[php]local max = MaxPower(unit)
local cur = Power(unit)
if max > 0 then
local _, types = UnitPowerType(unit)
local r, g, b = PowerColor(types)
return "|cff%02x%02x%02x%s|r", r, g, b, cur
end[/php]
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.