edit: took a close look and there is a bug in whole VehicleName function.
For now output is "Darkspear Raptor's Darkspear Raptor" xD
I'll try to look further and pick it out.
edit2: found it:
local owner_unit = unit:gsub("vheicle", "")
See it?;P
Oops. Will be fixed in my next push. Does that resolve what you wanted it to do? Or did you still just only want the players name?
Oops. Will be fixed in my next push. Does that resolve what you wanted it to do? Or did you still just only want the players name?
It "almost" solved it. Was getting "Garaddon's Darkspear Raptor", but i wanted only "Garaddon". After a quick tutorial for gsub i achieved what i wanted;P
However for raid frame it was a bit tricky to resolve driver's unitId.
if UnitAura(unit,"Unbalancing Strike",nil,"HARMFUL") then
-- something
end
Honestly, I have no idea how to put icons in FontStrings. I simply haven't looked at how that is implmented. I'll probably add a function like Icon to help with that. I just haven't gotten to it. I'm assuming there's some sort of escape code to put them in.
I looked into this. Icons are very easy to use, I'm not going to bother to add a utility function for it since all the DogTag one does is cat stuff together.
|TPATH_TO_ICON:SIZE|t
If SIZE is zero it seems to just use the default size for the texture.
So your DogTag to LuaText would be:
if UnitAura(unit,"Unbalancing Strike",nil,"HARMFUL") then
return "|TInterface/Icons/ability_warrior_decisivestrike:0|t"
end
If you're going to be looking for a lot of debuffs and setting icons something like this might be best:
local i = 1
while true do
local name = UnitAura(unit,i,"HARMFUL")
if not name then
break
elseif name == "Something" then
return "|TSomeIcon:0|t"
elseif name == "Something2" then
return "|TSomeIcon2:0|t"
end
i = i + 1
end
Just keep repeating the elseif block for more. Repeated calls to C space looking for multiple auras by name probably isn't efficient but I haven't benchmarked it.
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
Added PVPDuration() to the ScriptEnv best way to do this is now:
local text = AFK(unit) or DND(unit)
if not text then
local pvp = PVPDuration(unit)
if pvp then
text = FormatDuration(pvp)
end
end
if text then
return "|cffff0000%s|r",text
end
Is there some way to implement wrapping in a textstring? I did an ugly job of this in DogTags by replacing all spaces with \n but I do not know enough about Lua to know whether this can be done. Or is it possible to add this feature to Pitbull itself?
I don't think there is directly. You can use \n in the format string it'll behave the same way as it did in DogTags e.g.:
return "foo\nbar\nbaz"
On a related note, I've noticed that while left aligned strings truncate, right aligned strings do not and the text continues outside of the frame it's in. Or at least that's the case on frames that are mirrored horizontally.
That would be a PB4 bug. Truncation is handled by PB4 core. Open a ticket I can try and nudge ckknight into looking at it. The layout code that does all of that gives me a headache. :D
Something I hadn't mentioned but I figured I would since it was something that I remembered just now. Errors from your scripts should look like so:
[string "PitBull4_LuaTexts:Target:Test"] line 1:
attempt to call global 'retrun' (a nil value)
or
PitBull4_LuaTexts:Target:Test caused the following error:
bad argument #2 to 'SetFormattedText' (string expected, got nil)
In the case of the first type this means there's some sort of syntax or run time error in your script. In the case of the second it means that argument #2 to SetFormattedText was nil when it should have been a string. Your return values from your script are the arguments to SetFormattedText. The FontString is actually argument #1 so argument #2 is the first return value and so on.
You'll note that both have this text:
PitBull4_LuaTexts:Target:Test
This is there to help you identify the text causing the error. PitBull4_LuaTexts is of course the module.
Target is the Layout the text is configured in.
Test is the name of the text configuration.
You can catch those errors with any sort of error catcher that you'd usually use such as Swatter, BugSack, etc...
Scripts that produce any errors will also set the actual text to {err} to help people who might not have an error catcher realize it's not working right.
All of these errors are trapped so at no point in time should an error ever cause PitBull4 or LuaTexts to stop working properly.
I looked into this. Icons are very easy to use, I'm not going to bother to add a utility function for it since all the DogTag one does is cat stuff together.
I don't get Abbreviate() working, maybe I'm just blind. There is this abbreviate() funciton talked about some pages ago, but how exactly do I get a unit name abbreviated to 3 chars? *confused*
I don't get Abbreviate() working, maybe I'm just blind. There is this abbreviate() funciton talked about some pages ago, but how exactly do I get a unit name abbreviated to 3 chars? *confused*
Looks like I goofed up when I put it in. However, I don't think it works the way you think it does, here's the example from DogTags:
Hello World => HW
If you just want the first 3 characters for the name do this:
string.sub(Name(unit),1,3)
and the
local text = AFK(unit) or DND(unit)
if not text then
local pvp = PVPDuration(unit)
if pvp then
text = FormatDuration(pvp)
end
end
if text then
return "|cffff0000%s|r",text
end
you posted earlier is {err}'ing on me when not dnd/afk'ing
If you just want the first 3 characters for the name do this:
string.sub(Name(unit),1,3)
This works fine, thanks.
The solution for tracking more buffs or debuffs with icons is also working, but it has to be slightly changed if one wants to track more than one buff/debuff at once, like e.g. rejuv and lifebloom on one player.
Hmm, probably not. I think it's mostly useful for tooltips. For one thing it has to tooltip scan to get the information. If you're wanting text for your current zone and not some arbitrary unit you can use these functions: http://www.wowwiki.com/API#Location_Functions
But I'm very disinclined to add any tooltip scanning code. Because it sucks.
and the
local text = AFK(unit) or DND(unit)
if not text then
local pvp = PVPDuration(unit)
if pvp then
text = FormatDuration(pvp)
end
end
if text then
return "|cffff0000%s|r",text
end
you posted earlier is {err}'ing on me when not dnd/afk'ing
Working fine here, I'm guessing you haven't updated to the new PVPDuration(unit) function.
I have been trying for some hours to get Race abbreviate, so I did :
local dr,dg,db = DifficultyColor(unit)
return "|cff%02x%02x%02x%s%s|r %s",dr,dg,db,Level(unit),Classification(unit) and '+' or '',string.sub(SmartRace(unit),1,3) or ''
but the result give : Blo and not BE as I am trying to get for Blood Elfe.
I tried to use ShortRace too but it seems not working either.
Do I have to create that myself in the scritp ? before I start doing that I want to be sur of it :)
Also on a side note, the PVPduration works fine for me.
Abbreviate was bugged until just a bit ago. I added it but didn't bother to test it and it wasn't working right. It's fixed now if you update to the latest version.
However, Abbreviate(SmartRace(unit)) is probably not what he wants because I'm pretty sure there's at least one creature with a space in the name. Maybe I'm wrong.
Incidentally, I think Abbreviate is a horrible name. It's more like Acronymize (not that is really a word).
Abbreviate was bugged until just a bit ago. I added it but didn't bother to test it and it wasn't working right. It's fixed now if you update to the latest version.
However, Abbreviate(SmartRace(unit)) is probably not what he wants because I'm pretty sure there's at least one creature with a space in the name. Maybe I'm wrong.
Incidentally, I think Abbreviate is a horrible name. It's more like Acronymize (not that is really a word).
In fact its not Abbreviate, and not either Truncate :)
I made some search to compare with Dogtags and how I was getting BE for Blood Elf. My code was
[(Level (if Classification then
'+'
end)):DifficultyColor] [ShortRace]
So I was trying to adapt to Lua.text but there is no ShortRace with text.lua and I get an error each time I try to use Short.
In Dogtags the function was
DogTag:AddTag("Unit", "ShortRace", {
code = function(value, unit)
return ShortRace_abbrev[value or UnitRace(unit)]
end,
arg = {
'value', 'string;undef', '@undef',
'unit', 'string;undef', 'player'
},
ret = "string;nil",
doc = L["Return a shortened race of unit, or shorten a race"],
example = ('[ShortRace] => %q; [%q:ShortRace] => %q; ["Hello":ShortRace] => ""'):format(L["Blood Elf_short"], L["Blood Elf"], L["Blood Elf_short"]),
category = L["Abbreviations"]
})
Do I have to create my own script to get that working ?
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Oops. Will be fixed in my next push. Does that resolve what you wanted it to do? Or did you still just only want the players name?
It "almost" solved it. Was getting "Garaddon's Darkspear Raptor", but i wanted only "Garaddon". After a quick tutorial for gsub i achieved what i wanted;P
However for raid frame it was a bit tricky to resolve driver's unitId.
I looked into this. Icons are very easy to use, I'm not going to bother to add a utility function for it since all the DogTag one does is cat stuff together.
|TPATH_TO_ICON:SIZE|t
If SIZE is zero it seems to just use the default size for the texture.
So your DogTag to LuaText would be:
If you're going to be looking for a lot of debuffs and setting icons something like this might be best:
Just keep repeating the elseif block for more. Repeated calls to C space looking for multiple auras by name probably isn't efficient but I haven't benchmarked it.
Added PVPDuration() to the ScriptEnv best way to do this is now:
I don't think there is directly. You can use \n in the format string it'll behave the same way as it did in DogTags e.g.:
That would be a PB4 bug. Truncation is handled by PB4 core. Open a ticket I can try and nudge ckknight into looking at it. The layout code that does all of that gives me a headache. :D
[string "PitBull4_LuaTexts:Target:Test"] line 1:
attempt to call global 'retrun' (a nil value)
or
PitBull4_LuaTexts:Target:Test caused the following error:
bad argument #2 to 'SetFormattedText' (string expected, got nil)
In the case of the first type this means there's some sort of syntax or run time error in your script. In the case of the second it means that argument #2 to SetFormattedText was nil when it should have been a string. Your return values from your script are the arguments to SetFormattedText. The FontString is actually argument #1 so argument #2 is the first return value and so on.
You'll note that both have this text:
PitBull4_LuaTexts:Target:Test
This is there to help you identify the text causing the error. PitBull4_LuaTexts is of course the module.
Target is the Layout the text is configured in.
Test is the name of the text configuration.
You can catch those errors with any sort of error catcher that you'd usually use such as Swatter, BugSack, etc...
Scripts that produce any errors will also set the actual text to {err} to help people who might not have an error catcher realize it's not working right.
All of these errors are trapped so at no point in time should an error ever cause PitBull4 or LuaTexts to stop working properly.
You were right. HostileColor will be fixed in the next push.
Thanks very much.
local r,g,b = AggroColor(unit)
local cur,max = HP(unit),MaxHP(unit)
local r,g,b = HPColor(cur,max)
local _,power_type = UnitPowerType(unit)
local r,g,b = PowerColor(power_type)
local name,reaction = GetWatchedFactionInfo()
local r,g,b = ReactionColor(reaction)
Enjoy.
Looks like I goofed up when I put it in. However, I don't think it works the way you think it does, here's the example from DogTags:
Hello World => HW
If you just want the first 3 characters for the name do this:
string.sub(Name(unit),1,3)
and the
local text = AFK(unit) or DND(unit)
if not text then
local pvp = PVPDuration(unit)
if pvp then
text = FormatDuration(pvp)
end
end
if text then
return "|cffff0000%s|r",text
end
you posted earlier is {err}'ing on me when not dnd/afk'ing
keep up the good work :)
This works fine, thanks.
The solution for tracking more buffs or debuffs with icons is also working, but it has to be slightly changed if one wants to track more than one buff/debuff at once, like e.g. rejuv and lifebloom on one player.
Hmm, probably not. I think it's mostly useful for tooltips. For one thing it has to tooltip scan to get the information. If you're wanting text for your current zone and not some arbitrary unit you can use these functions:
http://www.wowwiki.com/API#Location_Functions
But I'm very disinclined to add any tooltip scanning code. Because it sucks.
Working fine here, I'm guessing you haven't updated to the new PVPDuration(unit) function.
but the result give : Blo and not BE as I am trying to get for Blood Elfe.
I tried to use ShortRace too but it seems not working either.
Do I have to create that myself in the scritp ? before I start doing that I want to be sur of it :)
Also on a side note, the PVPduration works fine for me.
string.sub => Truncate from DogTags
However, Abbreviate(SmartRace(unit)) is probably not what he wants because I'm pretty sure there's at least one creature with a space in the name. Maybe I'm wrong.
Incidentally, I think Abbreviate is a horrible name. It's more like Acronymize (not that is really a word).
you were right, PB wasnt updated.
another isue:
throws a {err} at me, is it just my code or?
Should be:
In fact its not Abbreviate, and not either Truncate :)
I made some search to compare with Dogtags and how I was getting BE for Blood Elf. My code was
So I was trying to adapt to Lua.text but there is no ShortRace with text.lua and I get an error each time I try to use Short.
In Dogtags the function was
Do I have to create my own script to get that working ?