if we want for example PVP with the Duration, do we have to create that first in the LUA, then in the macro ?
Really don't understand what you're asking here.
Can we shorten the name value so it contains only AFK, pvpduration, DEAD ?
I personally always removed my name on my player frame as I know who I am :)
I tried to suppress the name and keep the AFK but it says error.
You probably need to remove the format tags from the string that it returns first. %s means a string %d means a signed integer.
Can we add Color to some taggs ?
To switch to a given color use:
|cffRRGGBB where RR, GG, BB is the hex value of the color you want from 0 to 255. When you want to turn off the color add |r in. This is the color escaping mechanism the game uses.
There are a couple utility functions to give you colors:
HostileColor()
ClassColor()
DifficultyColor()
Each returns 3 values that you can put into the RGB. To get the hex you use the format %02x in the format string.
Guys, LuaText is Lua, parsed and compiled by the Lua engine itself. If you don't know Lua and have never written an add-on for WoW, and don't want to learn on your own, you have no business using LuaTexts. Please don't swamp Shefki with hundreds of useless posts asking for help writing Lua. Stick with DogTags or do some research. Shefki's being really nice so far, but all these responses are taking time away from further improving Pitbull.
Maybe if anyone has time, I would be interested in 3 things I used to do with the dogtags:
Abbreviate, Afk:formatduration without it saying afk because the text usually got way big, so I had just the playername:afktime aaand for better reading I had outlined font.
Just add this to your ScriptEnv.lua
local function Abbreviate(value)
if value:find(" ") then
return value:gsub(" *([^ ]+) *", abbreviate)
else
return value
end
end
ScriptEnv.Abbreviate = Abbreviate
Seems simple enough I'll go ahead an add it myself.
For AFK time I'll add another utility function to access just it. It's kinda a pain to get at my timer table from the scripts.
BTW i didn't know that %02x converts to hex. I have spent some time with calc instead >< Does it accept only integers or fractions (like 0.56) are fine as well?
It'll accept fractions. However if you have the colors in the integer format wow uses for the API just multiply by 255 before you put it in the return.
e.g.
return "|cff%02x%02x%02xLook Red|r",1.0*255,0*255,0*255
Guys, LuaText is Lua, parsed and compiled by the Lua engine itself. If you don't know Lua and have never written an add-on for WoW, and don't want to learn on your own, you have no business using LuaTexts. Please don't swamp Shefki with hundreds of useless posts asking for help writing Lua. Stick with DogTags or do some research. Shefki's being really nice so far, but all these responses are taking time away from further improving Pitbull.
I expected a fair amount of questions. I figure if I answer them then the community will learn and then other people can answer for me later.
I think everyone should realize that DogTags had a learning curve to it as well. It was probably much easier than LuaTexts. However, the time spent learning LuaTexts is mostly spent learning Lua. The knowledge you gain for learning it can be used towards writing other adds, fixing bugs in addons, or heck even patching in things you wish your addons have. Not to mention a whole bunch of things entirely unrelated to the game.
Do we have any way to set the outline of the text? Not seeing that exposed through SetFormattedText.
Just call Outline() or ThickOutline(). Alpha(number) also exists. They produce no return but let you mess with the FontString.
You also have direct access to the FontString by the name of font_string in the scripts. But be careful, dragons exist in these waters. The FontStrings are recycled and PitBull4 does things to them outside LuaTexts control. Things may not work the way you expect. But I can assure you that the functions I mentioned above are safe.
Someone at some point replied to the post asking about if this was really less overhead and said something about how you didn't have all the features of DogTags up and running all the time that you only had what you put in your code.
I want highlight this a bit and explain how this is 99% true. DogTags listens to a bunch of events all the time to build caches for the tags. Not everything is implemented this way but a lot more is than I'd care to think about. In general LuaTexts handles events as follows:
You build a text, you set the event on it. Where your text is created by PitBull4 on a frame it we start listening to the event for it. When your frame goes away we stop. If two texts use the same event the first frame will start us listening for the event and the event will stay listened to until no text in use needs it.
There are a couple exceptions to this:
UNIT_SPELLCAST_SENT which happens only for your own spell casts is always watched. We save a couple variables. This is necessary because of the auto-hide cast bars in PB4. Those cast bars don't exist until the unit starts casting and as a result neither do the texts. The information given in that event is not available any other way, you miss the even it's gone forever.
PARTY_MEMBERS_CHANGED which happens anytime your group changes. We have a table of units to guids for people in your group. We use this table for knowing who to watch for offline timers, dnd timers, afk timers and dead timers.
A once a second check for units offline, dead, dnd and afk state. Needed to support the timers mentioned above.
I'll probably implement checkboxes to turn these off for people not using them.
Everything else I needed to implement the defaults in PB4 required none of this. I really wish I could have implmented the default texts without having to resort to this sort of stuff. But I did and it's largely a limitation of the Blizzard API.
Just call Outline() or ThickOutline(). Alpha(number) also exists. They produce no return but let you mess with the FontString.
You also have direct access to the FontString by the name of font_string in the scripts. But be careful, dragons exist in these waters. The FontStrings are recycled and PitBull4 does things to them outside LuaTexts control. Things may not work the way you expect. But I can assure you that the functions I mentioned above are safe.
Excellent, that worked well.
I see a typo in the event list. UNIT_SEPLLCAST_CHANNEL_STOP should be UNIT_SPELLCAST_CHANNEL_STOP.
You probably need to remove the format tags from the string that it returns first. %s means a string %d means a signed integer.
To switch to a given color use:
|cffRRGGBB where RR, GG, BB is the hex value of the color you want from 0 to 255. When you want to turn off the color add |r in. This is the color escaping mechanism the game uses.
There are a couple utility functions to give you colors:
HostileColor()
ClassColor()
DifficultyColor()
Each returns 3 values that you can put into the RGB. To get the hex you use the format %02x in the format string.
I am really sorry to bother you and I will not after that one last.
Under Dogtags I have this :
["code"] = "[(AFK:Red or DND:Red or PvPDuration:FormatDuration:Red)]",
What could I do to have also the same thing with LUA TEXT ?
I figured the basic how to do with LUA, and I know after some days I will be able to write what I want, but I dont find anything in LUA text that is related to pvp so I am wondering how to formulate the event.
If you could only answer me on that one I will not bother you anymore, I promise
I am really sorry to bother you and I will not after that one last.
Under Dogtags I have this :
["code"] = "[(AFK:Red or DND:Red or PvPDuration:FormatDuration:Red)]",
What could I do to have also the same thing with LUA TEXT ?
local afk,dnd,pvp = AFK(unit), DND(unit)
if UnitIsUnit(unit,"player") then
pvp = IsPVPTimerRunning()
end
if afk then
return "|cffff0000%s|r",afk
elseif dnd then
return "|cffff0000%s|r",dnd
elseif pvp then
UpdateIn(0.25)
return "|cffff0000%s|r",FormatDuration(GetPVPTimer()/1000)
end
Tested now and it works. Ohh and the event you want to watch is PLAYER_FLAGS_CHANGED
I probably should provide a convenience function for GetPVPTimer()
Since I figure this is going to come up shortly, I thought I'd mention it.
Dealing with timers. If you want to put some sort of timer on the screen you need to refresh that every so often in order to change the text. The convenience functions that return timers to you seem to magically make this happen. They're doing a little extra work for you that you can't see (well you can if you look at ScriptEnv.lua). In particular they call UpdateIn(seconds) which is another conveience function that asks LuaTexts to schedule an update on that text.
The seconds passed can be fractional. So for instance in the PVP timer example above I used: UpdateIn(0.25) which will update the timer 4 times a second.
After getting a little error on the pvp part, it finally works if I do this :
local afk,dnd,pvp = AFK(unit), DND(unit)
if UnitIsUnit(unit,"player") then
pvp = IsPVPTimerRunning()
end
if afk then
return "|cffff0000%s|r",afk
elseif dnd then
return "|cffff0000%s|r",dnd
elseif pvp then
UpdateIn(0.25)
return "|cffff0000%s|r",math.floor (GetPVPTimer()/1000)
end
PVP timer format is then given in secondes not in minutes as in DogTags, but it works and its all red :)
Thank you
With the version you just updated, I got now the the timer pvp in minutes as well :) but still with Math.Floor
After getting a little error on the pvp part, it finally works if I do this :
If you're getting an error about FormatDuration you probably just need to update. I realized I didn't add it into the environment for the scripts and did a push that fixed it. I've found a few other bugs that I'm fixing now in /FormatDuration. Interestingly enough, they seem to be in DogTags too.
Bahh edited while I was typing/pushing some fixes.
cant get Status(unit) to work (only tested on mobs) using the built in health absolute short.
"local s = Status(unit)
if s then
return s
end
return "%s/%s",Short(HP(unit),true),Short(MaxHP(unit),true)"
aka I killed a mob and it only showed up as (example) 0/324 where I would think it should be "Dead 0/324"
After looking at that PVP thing a bit more this would be more efficient:
local afk,dnd = AFK(unit), DND(unit)
if afk then
return "|cffff0000%s|r",afk
elseif dnd then
return "|cffff0000%s|r",dnd
else
local pvp = UnitIsUnit(unit,"player") and IsPVPTimerRunning()
if pvp then
UpdateIn(0.25)
return "|cffff0000%s|r",FormatDuration(GetPVPTimer()/1000)
end
end
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Really don't understand what you're asking here.
You probably need to remove the format tags from the string that it returns first. %s means a string %d means a signed integer.
To switch to a given color use:
|cffRRGGBB where RR, GG, BB is the hex value of the color you want from 0 to 255. When you want to turn off the color add |r in. This is the color escaping mechanism the game uses.
There are a couple utility functions to give you colors:
HostileColor()
ClassColor()
DifficultyColor()
Each returns 3 values that you can put into the RGB. To get the hex you use the format %02x in the format string.
Just add this to your ScriptEnv.lua
Seems simple enough I'll go ahead an add it myself.
For AFK time I'll add another utility function to access just it. It's kinda a pain to get at my timer table from the scripts.
It'll accept fractions. However if you have the colors in the integer format wow uses for the API just multiply by 255 before you put it in the return.
e.g.
return "|cff%02x%02x%02xLook Red|r",1.0*255,0*255,0*255
I expected a fair amount of questions. I figure if I answer them then the community will learn and then other people can answer for me later.
I think everyone should realize that DogTags had a learning curve to it as well. It was probably much easier than LuaTexts. However, the time spent learning LuaTexts is mostly spent learning Lua. The knowledge you gain for learning it can be used towards writing other adds, fixing bugs in addons, or heck even patching in things you wish your addons have. Not to mention a whole bunch of things entirely unrelated to the game.
Just call Outline() or ThickOutline(). Alpha(number) also exists. They produce no return but let you mess with the FontString.
You also have direct access to the FontString by the name of font_string in the scripts. But be careful, dragons exist in these waters. The FontStrings are recycled and PitBull4 does things to them outside LuaTexts control. Things may not work the way you expect. But I can assure you that the functions I mentioned above are safe.
I want highlight this a bit and explain how this is 99% true. DogTags listens to a bunch of events all the time to build caches for the tags. Not everything is implemented this way but a lot more is than I'd care to think about. In general LuaTexts handles events as follows:
You build a text, you set the event on it. Where your text is created by PitBull4 on a frame it we start listening to the event for it. When your frame goes away we stop. If two texts use the same event the first frame will start us listening for the event and the event will stay listened to until no text in use needs it.
There are a couple exceptions to this:
UNIT_SPELLCAST_SENT which happens only for your own spell casts is always watched. We save a couple variables. This is necessary because of the auto-hide cast bars in PB4. Those cast bars don't exist until the unit starts casting and as a result neither do the texts. The information given in that event is not available any other way, you miss the even it's gone forever.
PARTY_MEMBERS_CHANGED which happens anytime your group changes. We have a table of units to guids for people in your group. We use this table for knowing who to watch for offline timers, dnd timers, afk timers and dead timers.
A once a second check for units offline, dead, dnd and afk state. Needed to support the timers mentioned above.
I'll probably implement checkboxes to turn these off for people not using them.
Everything else I needed to implement the defaults in PB4 required none of this. I really wish I could have implmented the default texts without having to resort to this sort of stuff. But I did and it's largely a limitation of the Blizzard API.
Excellent, that worked well.
I see a typo in the event list. UNIT_SEPLLCAST_CHANNEL_STOP should be UNIT_SPELLCAST_CHANNEL_STOP.
I am really sorry to bother you and I will not after that one last.
Under Dogtags I have this :
["code"] = "[(AFK:Red or DND:Red or PvPDuration:FormatDuration:Red)]",
What could I do to have also the same thing with LUA TEXT ?
I figured the basic how to do with LUA, and I know after some days I will be able to write what I want, but I dont find anything in LUA text that is related to pvp so I am wondering how to formulate the event.
If you could only answer me on that one I will not bother you anymore, I promise
Tested now and it works. Ohh and the event you want to watch is PLAYER_FLAGS_CHANGED
I probably should provide a convenience function for GetPVPTimer()
Not aware of any HPColor tag on the Absolute Short Health text. But I didn't pull that one in. Probably could, if there's a use for it.
Dealing with timers. If you want to put some sort of timer on the screen you need to refresh that every so often in order to change the text. The convenience functions that return timers to you seem to magically make this happen. They're doing a little extra work for you that you can't see (well you can if you look at ScriptEnv.lua). In particular they call UpdateIn(seconds) which is another conveience function that asks LuaTexts to schedule an update on that text.
The seconds passed can be fractional. So for instance in the PVP timer example above I used: UpdateIn(0.25) which will update the timer 4 times a second.
There isn't a preset for that with DogTag, I was just using a custom one that looks like and I was wondering if - anyone that was using the same - managed to write it in Lua since I don't look to be able to do so.
After getting a little error on the pvp part, it finally works if I do this :
PVP timer format is then given in secondes not in minutes as in DogTags, but it works and its all red :)
Thank you
With the version you just updated, I got now the the timer pvp in minutes as well :) but still with Math.Floor
If you're getting an error about FormatDuration you probably just need to update. I realized I didn't add it into the environment for the scripts and did a push that fixed it. I've found a few other bugs that I'm fixing now in /FormatDuration. Interestingly enough, they seem to be in DogTags too.
Bahh edited while I was typing/pushing some fixes.
"local s = Status(unit)
if s then
return s
end
return "%s/%s",Short(HP(unit),true),Short(MaxHP(unit),true)"
aka I killed a mob and it only showed up as (example) 0/324 where I would think it should be "Dead 0/324"