 |
| Welcome to Elitist Jerks |
We're testing some new features on the site regarding OpenID registration and coordination with gamerDNA. If you experience any issues with registering an account, please take the time to fill out a report and send it to this e-mail address. We would appreciate any assistance you could provide in making sure everything is functioning as intended. Thanks!
If this is your first visit, please be sure to check out the FAQ and the forum rules. Users must register to post and new registrations are subject to a one day "mute" period to get acquainted with the community.
|
06/19/09, 5:42 PM
|
#51
|
|
Von Kaiser
|
Originally Posted by Dendrek
Two simple questions:
How do you get power color? PowerColor(unit) doesn't seem to work.
|
PowerColor doesn't take a unit argument it takes the name of the power.
local _,power_name = UnitPowerType(unit)
local r,g,b = PowerColor(power_name)
|
How do you format numbers to be separated by commas? E.g. 2000000 -> 2,000,000.
|
I need to add a helper SeperateDigits to do this like in DogTags. You can do what this guy did for the time being:
WowAce Forums - View Single Post - PitBull 4.0
Edit: Most recent push will have SeparateDigits now.
Last edited by Shefki : 06/19/09 at 5:53 PM.
|
|
|
|
|
|
06/19/09, 9:02 PM
|
#52
|
|
Piston Honda
|
So I just updated and I got the following error, which wasn't there before:

[2009/06/19 16:52:56-589-x1]: PitBull4_LuaTexts:Party - L:Lua:Class caused the following error::
bad argument #6 to 'SetFormattedText' (string expected, got nil):
PitBull4-r20090619205137\Modules\LuaTexts\LuaTexts.lua:639: in function <...erface\AddOns\PitBull4\Modules\LuaTexts\LuaTexts.lua:595>
PitBull4-r20090619205137\Modules\LuaTexts\LuaTexts.lua:1135: in function `AddFontString'
PitBull4-r20090619205137\ModuleHandling\TextProviderModule.lua:116: in function `UpdateFrame'
PitBull4-r20090619205137\ModuleHandling\Module.lua:271: in function `Update'
PitBull4-r20090619205137\UnitFrame.lua:527: in function `Update'
PitBull4-r20090619205137\UnitFrame.lua:553: in function `UpdateGUID'
PitBull4-r20090619205137\UnitFrame.lua:243: in function <Interface\AddOns\PitBull4\UnitFrame.lua:239>
<in C code>: in function `Show'
Interface\FrameXML\SecureTemplates.lua:748: in function <Interface\FrameXML\SecureTemplates.lua:660>:
Interface\FrameXML\SecureTemplates.lua:955: in function `SecureGroupHeader_Update':
Interface\FrameXML\SecureTemplates.lua:541: in function <Interface\FrameXML\SecureTemplates.lua:539>:
---
Here is "Lua:Class" within my "Party-L" layout
local dr,dg,db = DifficultyColor(unit)
local form = DruidForm(unit)
local clas = Class(unit)
if clas=='Priest' then
local i = 1
while true do
local name,_,icon = UnitAura(unit,i,"HELPFUL")
if not name then
break
elseif name == "Shadowform" then
form = "Sh"
end
i = i + 1
end
end
if UnitIsPlayer(unit) then
local cr,cg,cb = ClassColor(unit)
if form then
return "|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r |cff%02x%02x%02x(%s)|r "
,255,204,0, SmartRace(unit),cr,cg,cb,clas,cr,cg,cb,form or ''
else
return "|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r"
,255,204,0, SmartRace(unit),cr,cg,cb,clas or ''
end
else
return "|cff%02x%02x%02x%s|r "
,255,204,0,SmartRace(unit) or ''
end
Does anybody see an error there?
|
correlation =/= causation
|
|
|
|
06/19/09, 9:13 PM
|
#53
|
|
Von Kaiser
Tauren Shaman
Jaedenar (EU)
|
4th line missing a 's' in 'class'
I'd need some help with converting this monster, if it's possible at all:
[ThickOutline][Level:Hide(Level(unit="player")):DifficultyColor " " (if ((Abbreviate(Name) ~= Name) and (Length(Name) > 21)) then
if IsPlayer then
Abbreviate(Name):Substring(1, (Length(Abbreviate(Name)) - 1)):Replace("", "."):Substring(2):Append(" "):Upper:ClassColor Name:Replace(" ", " "):Substring(-15, -1):Replace(" ", ""):Truncate(21, nil):Upper:ClassColor
else
Abbreviate(Name):Substring(1, (Length(Abbreviate(Name)) - 1)):Replace("", "."):Substring(2):Append(" "):Upper Name:Replace(" ", " "):Substring(-15, -1):Replace(" ", ""):Truncate(21, nil):Upper
end
elseif IsPlayer then
Name:Truncate(21, nil):Upper:ClassColor
else
Name:Truncate(21, nil):Upper
end)]
|
|
|
|
|
|
06/19/09, 9:22 PM
|
#54
|
|
Piston Honda
|
Originally Posted by Aximous
4th line missing a 's' in 'class'
|
heh, that is actually on purpose, I defined Class(unit) as clas, as confusing as it is (I should probably change that).
Regarding your tag conversion, I will try and work on it post-raid tonight. On the other hand, I probably will just pass out.
|
correlation =/= causation
|
|
|
|
06/19/09, 9:44 PM
|
#55
|
|
Von Kaiser
Tauren Shaman
Jaedenar (EU)
|
Ah indeed I missed that declaration somehow, other than that I couldn't find anything that could be a problem, about the tag I myself don't even have the courage to try translating that knowing that how much time I put in creating the dogtag.
|
|
|
|
|
|
06/19/09, 9:50 PM
|
#56
|
|
Piston Honda
|
Aximous: Could you describe the tag, in English, so it is easier to decode the DogTag?
|
correlation =/= causation
|
|
|
|
06/20/09, 3:27 AM
|
#57
|
|
Piston Honda
|
I wrote a tag with GetPetTimeRemaining() and it works fantastically (although my formatting method is probably not optimal:
ptime = GetPetTimeRemaining()
if ptime then
return '%s',floor(ptime/100+.5)/10
end
However, I can't figure out which event to use (I know I will have to add it). I looked through the WoWWiki pet events, and nothing seemed logical. Any ideas?
|
correlation =/= causation
|
|
|
|
06/20/09, 3:38 AM
|
#58
|
|
Von Kaiser
|
Originally Posted by Shefki
Yup it's a bug where I got lazy. I'll get it fixed.
|
Fixed in the next push. You'll have to reselect the default text form the dropdown as changes to the text defaults don't update the current code in use.
|
|
|
|
|
|
06/20/09, 6:19 AM
|
#59
|
|
Glass Joe
Night Elf Druid
Sylvanas (EU)
|
Hello, I would like some conversions:
Druid mana bar: When I use Lua:Power:Mini from the presets it shows my energy instead of mana. DogTag code:
[if not IsMana then
DruidMP:VeryShort
end]
And this is my NumTargeting code which showed how many people are targetting me or my target:
[if NumTargeting > 0 then
NumTargeting
end]
Shefki already gave me this code but it only works for my target. For myself, it's a bit buggy, when some people target me, it doesn't change the value or when noone is targetting me sometimes it shows 1.
local prefix,num,size = "raid",0,GetNumRaidMembers()
local size = GetNumRaidMembers()
if size <= 0 then
prefix = "party"
size = GetNumPartyMembers()
end
for u=1,size do
if UnitIsUnit(prefix..u.."target", unit) then
num = num + 1
end
end
if num > 0 then
return "%d", num
end
|
|
|
|
|
|
06/20/09, 8:49 AM
|
#60
|
|
Von Kaiser
|
Originally Posted by miLl3niUm
Hello, I would like some conversions:
Druid mana bar: When I use Lua:Power:Mini from the presets it shows my energy instead of mana. DogTag code:
[if not IsMana then
DruidMP:VeryShort
end]
|
if UnitPowerType(unit) ~= 0 then
return VeryShort(Power(unit,0))
end
|
Shefki already gave me this code but it only works for my target. For myself, it's a bit buggy, when some people target me, it doesn't change the value or when noone is targetting me sometimes it shows 1.
|
Setup a UNIT_TARGET event with the All checkbox checked.
|
|
|
|
|
|
06/20/09, 10:00 AM
|
#61
|
|
Glass Joe
Night Elf Druid
Sylvanas (EU)
|
Thank you, can you also convert this one too, please:
[if TypePower = "Mana" then
FractionalMP:Short " | " PercentMP:Percent
else
MP
end]
|
|
|
|
|
|
06/20/09, 12:13 PM
|
#62
|
|
Von Kaiser
Tauren Shaman
Jaedenar (EU)
|
Originally Posted by Hotan
Aximous: Could you describe the tag, in English, so it is easier to decode the DogTag?
|
Sure, basicly it writes the level in difficultycolor at first then the name of the unit, but if it's longer than 21 characters then it will write only the starting letters. ie. Very Long Named Mob of Supremacy will be displayed as V.L.N.M.O.S. but the Short Named Mob will be displayed as Short Named Mob
|
|
|
|
|
|
06/20/09, 1:27 PM
|
#63
|
|
Glass Joe
Night Elf Priest
Azjol-Nerub (EU)
|
Originally Posted by miLl3niUm
Thank you, can you also convert this one too, please:
[if TypePower = "Mana" then
FractionalMP:Short " | " PercentMP:Percent
else
MP
end]
|
Isn't that one of the presets from the dropdown meny?
|
|
|
|
|
|
06/20/09, 2:39 PM
|
#64
|
|
Piston Honda
|
Originally Posted by Aximous
Sure, basicly it writes the level in difficultycolor at first then the name of the unit, but if it's longer than 21 characters then it will write only the starting letters. ie. Very Long Named Mob of Supremacy will be displayed as V.L.N.M.O.S. but the Short Named Mob will be displayed as Short Named Mob
|
I take back my promise to help you. String truncation is not something I have learned yet.
|
correlation =/= causation
|
|
|
|
06/20/09, 4:22 PM
|
#65
|
|
Von Kaiser
|
Originally Posted by Aximous
Sure, basicly it writes the level in difficultycolor at first then the name of the unit, but if it's longer than 21 characters then it will write only the starting letters. ie. Very Long Named Mob of Supremacy will be displayed as V.L.N.M.O.S. but the Short Named Mob will be displayed as Short Named Mob
|
This isn't the whole tag but here's how to do the short name stuff you want:
local name = Name(unit)
if #name > 21 then
name = Abbreviate(name)
end
return name
Upper and loser case can be done with string.upper and string.lower.
Truncation is just a subset of string.sub where you use it like so: string.sub(value, 1, max) where max is the max length you want.
Replace is just another name for string.gsub(string, search, replace)
This should help in getting that converted. But I'm not entirely sure what you're trying to do with some of that and don't have the time atm to pull it apart.
|
|
|
|
|
|
06/20/09, 4:35 PM
|
#66
|
|
Von Kaiser
Tauren Shaman
Jaedenar (EU)
|
I know it's not the whole tag but it's the important part of it, the rest which isn't there I can translate myself. The stuff missing from your code is which puts the dots after each word abbreviation and the coloring. I guess I can figure something based on this, I'll post the results here.
Edit: One more question: is there some way to insert something in a string (like x.insert(s, "w") in c++) or I have to do everything with temp variables and gsubs?
Last edited by Aximous : 06/20/09 at 5:57 PM.
|
|
|
|
|
|
06/20/09, 5:36 PM
|
#67
|
|
Glass Joe
Night Elf Druid
Sylvanas (EU)
|
Originally Posted by Zeelian
Isn't that one of the presets from the dropdown meny?
|
No, the preset is Curr/Max | Percent
I want Curr/Max | Percent when its mana and Curr when it's energy.
|
|
|
|
|
|
06/20/09, 5:41 PM
|
#68
|
|
Piston Honda
|
Originally Posted by miLl3niUm
I want Curr/Max | Percent when its mana and Curr when it's energy.
|
if UnitPowerType(unit) == 0 then
cur,max=Power(unit),MaxPower(unit)
return "%s/%s | %s%%",cur,max,Percent(cur,max)
elseif UnitPowerType(unit) == 3 then
cur=Power(unit)
return cur
end
Here is Curr/Max | Percent when its mana and Curr when it's anything else.
if UnitPowerType(unit) == 0 then
cur,max=Power(unit),MaxPower(unit)
return "%s/%s | %s%%",cur,max,Percent(cur,max)
else
cur=Power(unit)
return cur
end
|
correlation =/= causation
|
|
|
|
06/20/09, 5:57 PM
|
#69
|
|
Von Kaiser
Tauren Shaman
Jaedenar (EU)
|
Got it working, it does pretty much the same as the old tag.
ThickOutline()
local dr,dg,db = DifficultyColor(unit)
local cr,cg,cb = ClassColor(unit)
local name, namee, level = Name(unit), "", Level(unit)
local temp, tempp, oname
local i = 1
oname = name
if level == Level("Player") then
level = ""
else
level = string.reverse(level)
level = string.gsub(level, "", " ", 1)
level = string.reverse(level)
end
if #name > 15 then
name = Abbreviate(name)
name = string.upper(name)
end
while i < #name + 1 do
temp = string.sub(name, -i, -i)
namee = string.gsub(namee, "", ".", 1)
namee = string.gsub(namee, "", temp, 1)
i = i + 1
end
if (#oname > 15) and (name ~= oname) then
if UnitIsPlayer(unit) then
return "|cff%02x%02x%02x%s|r|cff%02x%02x%02x%s|r",dr,dg,db,level,cr,cg,cb,namee
else
return "|cff%02x%02x%02x%s|r%s",dr,dg,db,level,namee
end
else
namee = string.sub(oname, 1, 15)
if UnitIsPlayer(unit) then
return "|cff%02x%02x%02x%s|r|cff%02x%02x%02x%s|r",dr,dg,db,level,cr,cg,cb,namee
else
return "|cff%02x%02x%02x%s|r%s",dr,dg,db,level,namee
end
end
Any ideas with which the code could be cleaned up a bit or is it good as it is?
Last edited by Aximous : 06/20/09 at 6:20 PM.
|
|
|
|
|
|
06/20/09, 8:53 PM
|
#70
|
|
Von Kaiser
|
Originally Posted by Aximous
Any ideas with which the code could be cleaned up a bit or is it good as it is?
|
You really shouldn't use reverse and gsub to add the space. You produce 4 strings just to add a space to the end of level if needed.
Just do something like this:
if level == Level("player") then
level = nil
end
return "%s%s%s",level or '',level and ' ' or '',otherstuff
The above would remove the need for temp entirely.
The ' ' and '' constants won't ever be reaped. It's no big deal for the SetFormattedText to put stuff together.
I doubt the string.upper after Abbreviate is necessary. Don't recall every seeing a name with an uncapped word in it. But I could be wrong.
I suspect this would be faster to insert the periods into the string:
namee = string.gsub(name, "(.)", "%1.")
tempp is entirely unused.
I'd think you really should change the last if then else block to just be:
if (#oname <= 15) or (name == oname) then
namee = string.sub(oname, 1, 15)
end
if UnitIsPlayer(unit) then
return "|cff%02x%02x%02x%s|r|cff%02x%02x%02x%s|r",dr,dg,db,level,cr,cg,cb,namee
else
return "|cff%02x%02x%02x%s|r%s",dr,dg,db,level,namee
end
Applying all of the above the final code would just be:
ThickOutline()
local dr,dg,db = DifficultyColor(unit)
local cr,cg,cb = ClassColor(unit)
local name, namee, level = Name(unit), "", Level(unit)
local oname = name
if level == Level("Player") then
level = nil
end
if #name > 15 then
name = Abbreviate(name)
end
namee = string.gsub(name, "(.)", "%1.")
if (#oname <= 15) or (name == oname) then
namee = string.sub(oname, 1, 15)
end
if UnitIsPlayer(unit) then
return "|cff%02x%02x%02x%s|r%s|cff%02x%02x%02x%s|r",dr,dg,db,level or '',level and ' ' or '',cr,cg,cb,namee
else
return "|cff%02x%02x%02x%s|r%s%s",dr,dg,db,level or '',level and ' ' or '',namee
end
Last edited by Shefki : 06/20/09 at 8:58 PM.
|
|
|
|
|
|
06/20/09, 9:41 PM
|
#71
|
|
Piston Honda
|
Is there currently any way to get my raid group in a LuaText? I haven't seen it as any of the stated functions, and I haven't had any luck looking for other ways to get Pitbull to display which raid group I'm in (on my unit frame)
|
|
|
|
|
|
06/20/09, 9:43 PM
|
#72
|
|
Von Kaiser
Tauren Shaman
Jaedenar (EU)
|
Hmm those are really impressive those are really much more elegant solutions. But learning gsub from google and with only minimal lua knowledge I was happy that I could make a working code with proper results. Anyway thanks for the help.
|
|
|
|
|
|
06/22/09, 10:51 AM
|
#73
|
|
Von Kaiser
Troll Priest
Mannoroth (EU)
|
I'm trying to adapt one of Hotan's texts so it works like my old Dogtag but it returns an error and I can't really figure out why
The Dogtags (just 1 of 3 but they are all built the same just with different debuffs) were my version of Demon to display if an enemy is properly debuffed. It displays the different categories of debuffs and colors them depending on the strength of the debuff (and yes, hidden debuffs are very evil, but it's also very annoying one can't distinguish between talented and untalented debuffs).
Anyways, this is my old dogtag:
[(if InGroup(unit="player") then
(if (IsEnemy ? ~IsPlayerOrPet) then
(if (HasAura("Demoralizing Shout") or HasAura("Demoralizing Roar")) then
"AP":Green
elseif HasAura("Curse of Weakness") then
"AP":Yellow
else
"AP":Red
end) (if HasAura("Infected Wounds") then
" AS":Green
elseif (HasAura("Thunder Clap") or HasAura("Frost Fever")) then
" AS":Yellow
elseif (HasAura("Judgement of Light") or HasAura("Judgement of Wisdom")) then
" AS":Color('ff8000')
else
" AS":Red
end) (if (HasAura("Curse of Tongues") or HasAura("Mind-numbing Poison") or HasAura("Slow")) then
" CS":Green
else
" CS":Red
end) (if (HasAura("Insect Swarm") or HasAura("Scorpid Sting")) then
" Hit":Green
else
" Hit":Red
end)
end)
end)]
And here's what I've done so far:

if not UnitIsFriend(unit,'player') then
local i = 1
local ap,as,cs,hit= 0,0,0,0
local apr,apg,apb = ff,00,00
local asr,asg,asb = ff,00,00
local csr,csg,csb = ff,00,00
local hr,hg,hb = ff,00,00
while true do
local name = UnitAura(unit,i,"HARMFUL")
if not name then
break
elseif name == "Demoralizing Shout" then
ap = 2
elseif name == "Demoralizing Roar" then
ap = 2
elseif name == "Curse of Weakness" then
if ap < 1 then
ap = 1
end
elseif name == "Infected Wounds" then
as = 3
elseif name == "Thunder Clap" then
if as < 2 then
as = 2
end
elseif name == "Frost Fever" then
if as < 2 then
as = 2
end
elseif name == "Judgement of Light" then
if as == 0 then
as = 1
end
elseif name == "Judgement of Wisdom" then
if as == 0 then
as = 1
end
elseif name == "Curse of Tongues" then
cs = 1
elseif name == "Mind-numbing Poison" then
cs = 1
elseif name == "Slow" then
cs = 1
elseif name == "Insect Swarm" then
hit = 1
elseif name == "Scorpid Sting" then
hit = 1
end
i = i + 1
end
if ap == 2 then
apr,apg,apb = 00,ff,00
elseif ap == 1 then
apr,apg,apb = 00,ff,ff
end
if as == 3 then
asr,asg,asb = 00,ff,00
elseif as == 2 then
asr,asg,asb = 00,ff,ff
elseif as == 1 then
asr,asg,asb = ff,80,00
end
if cs == 1 then
csr,csg,csb = 00,ff,00
end
if hit == 1 then
hr,hg,hb = 00,ff,00
end
return "|cff%02x%02x%02xAP|r |cff%02x%02x%02xAS|r |cff%02x%02x%02xCS|r |cff%02x%02x%02xHit|r",apr,apg,apb,asr,asg,asb,csr,csg,csb,hr,hg,hb
end
The beginning of my old dogtag (the being-in-group part and the no-pet part) are not really important to me but I can't figure where my syntax error is.
To shorten it I could probably use something like "Demo Shout" or "Demo Roar" but I didn't want to do any stupid errors because of my limited knowledge of boolean algebra...
Thanks for the help!
Edit:
Nevermind... just figured it out after reading Shefki's replys on the first page 
Replacing ff with 0xFF solved the problem^^
Last edited by Hamsda : 06/22/09 at 11:01 AM.
|
There are only 10 types of people... those who understand binary and those who don't.
|
|
|
|
06/22/09, 6:27 PM
|
#74
|
|
Glass Joe
|
I've been trying to convert some of my DogTags into Lua Text, and I've run into a question.
Shefki's second post in this thread consisted of some code to use buff icons when there was an active buff.
return "%s%s%s",fort and "|TPATH_TO_FORT_ICON:0|t" or '',spirit and "|TPATH_TO_SPIRIT_ICON:0|t" or '',shadow_prot and "|TPATH_TO_SHADOW_PROT_ICON:0|t" or ''
However, instead of using buff icons, I'm looking to return string representations of those buffs such as AI, F, S, BK, etc... My idea will be that the string will be colored gray if the buff is inactive, and when the unit receives that buff, it will change colors. The question I have is about returning those strings. Below, I've tried to follow your above code, but I've replaced the buff icons with colored text, or what I believe would return colored text.
return "%s%s%s%s%s%s%s%s",int and "AI:cff008aff|r" or "AI:cff505050|r", fort and "F:cfffffff|r" or "F:cff505050|r",spirit and "S:cffffff00|r" or "S:cff505050|r", shadow and "SP:cff8300fd|r" or "SP:cff505050|r", mark and "W:cffff00ce|r" or "W:cff505050|r", kings and "BK:cff5b82ff|r" or "BK:cff505050|r", wisdom and "BW:cffac54ff|r" or "BW:cff505050|r", might and "BM:cff883300|r" or "BM:cff505050|r"
Is this the proper way of returning colored strings, instead of the actual buff icon, to determine if the buff is active?
Last edited by Sofa : 06/22/09 at 6:28 PM.
Reason: Clarifying the Question
|
|
|
|
|
|
06/22/09, 7:01 PM
|
#75
|
|
Glass Joe
Blood Elf Paladin
Firetree
|
On page 2 I posted a link to the wowwiki page on escape codes (including how to colour strings.) It is different to how dogtags handles it.
Read this link for more info: UI Escape Sequences - WoWWiki - Your guide to the World of Warcraft
But the general idea is that a string in the format "|cAARRGGBB" changes the colour of any text following it to have AA alpha, RR red component, GG green component and BB blue component. (Where those pairs are in hex.)
"|r" returns the text to its default colour.
An example using the text you're using:
replace "AI:cff008aff|r" with "|cff008affAI|r" and it should work.
|
|
|
|
|
|
|