I'm guessing it's just some pathetic error on my part, but it's annoying me.
Anyone who can give me some insight on what's wrong with my code?
The second argument you're passing to Power() is rage or mana which isn't defined in the text so it's passing nil, which is the same as passing no 2nd argument at all. The power type is specified by passing an integer that corresponds to the power type.
However, even replacing the proper constants (mana with SPELL_POWER_MANA and rage with SPELL_POWER_RAGE) won't fix your code because Power() probably returns 0 for the current power type and 0 evaluates to true in Lua.
You should just check the power type directly with UnitPowerType().
The second argument you're passing to Power() is rage or mana which isn't defined in the text so it's passing nil, which is the same as passing no 2nd argument at all. The power type is specified by passing an integer that corresponds to the power type.
However, even replacing the proper constants (mana with SPELL_POWER_MANA and rage with SPELL_POWER_RAGE) won't fix your code because Power() probably returns 0 for the current power type and 0 evaluates to true in Lua.
You should just check the power type directly with UnitPowerType().
E.g. UnitPowerType(unit) == SPELL_POWER_MANA
Thank you for the very fast reply! Works like a charm.
I'm trying to get Efflorescence (druid AoE heal) to show up via
local name = UnitAura(unit,"Efflorescence","HELPFUL")
etc. etc.
But then I noticed Efflorescence is just an AoE heal with periodic ticks, and does not show up in the bufflist like Wild Growth or Tranquility... So it's not an aura.
There is an addon which checks for people standing in your Efflorescence circle using SPELL_AURA_APPLIED but I can't get that to work either...
I've been working on a luatext for casting that will color and adjust opacity for spells based on whether they are cast by friend or foe, and whether they are interruptible or not. I found that i tend to focus more on the text color than the color of the bar behind it for some reason : /....anyway I think I have it working pretty well, and I've tested it on all sort of mobs to make sure it works as expected. It seems ok until I get into certain boss encounters in 5 mans, where it will often show spells that cannot be interrupted as interruptible while the bar behind it indicates that it can't. Again I've tested on various barrens mobs, making sure to find a non-interrptible cast, as well as a non int. channeled spell, an interruptible cast and an interruptible channeled spell. I'm still pretty green when it comes to lua and programming in general and I'm wondering if I've done something wrong here. I'm particularly unsure about the proper use of parenthesis around the "and" and "or" operators.
local cast_data = CastData(unit)
local _,_,_,_,_,_,_,_,nonintcast = UnitCastingInfo(unit)
local _,_,_,_,_,_,_,nonintchan = UnitChannelInfo(unit)
local friend = UnitIsFriend("player", unit)
local r,g,b = 255,255,255
local ir,ig,ib = 255,32,32
local noir,noig,noib = 132,132,132
local stopr,stopg,stopb = 132,132,132
local maxstrlen = 30
local opacity
Outline()
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
r,g,b = stopr,stopg,stopb
stop_duration = GetTime() - stop_time
elseif (nonintcast == true or nonintchan == true) and unit ~= "player" then
r,g,b = noir,noig,noib
else
if not friend then
r,g,b = ir,ig,ib
end
end
if (nonintcast ~= true and nonintchan ~= true and friend == nil) then
opacity = .5
else
opacity = .25
end
Alpha(-(stop_duration or 0) + opacity)
if stop_message then
return "|cff%02x%02x%02x%s|r",r,g,b,stop_message
else
if strlen(spell) >= maxstrlen then
return "|cff%02x%02x%02x%s|r",r,g,b,Abbreviate(spell)
else
return "|cff%02x%02x%02x%s|r",r,g,b,strupper(spell)
end
end
end
return ConfigMode()
If anyone can see any major flaws in this or can help me understand why certain boss abilities would be inconsistent with my barrens testing results I would appreciate it. Thanks ; )
P.S. the unit ~= "player" part is to prevent what appears to be a bug that occurs when you target yourself and cast a "cast" spell. This bug affects the bar color as well so I know that problem isn't an issue with just my luatext, but I've attempted to work around it by checking to see if the unit is the "player". That's a whole different issue though and I've posted a ticket about it (still pending review)
I brought up the topic of LuaTexts' future. The premise is LuaTexts is beginning to leak into other addon discussions, and some confusion is just barely starting to form between the differing LuaTexts implementations. I am promoting the next stage in LibScriptable's development; I'm giving it to the community. And I'm offering at least one solution to preventing LuaTexts from becoming a bad taste in people's mouths -- use LibScriptable's LuaTexts plugin as a semi-official platform for use by addon authors when writing LuaTexts addons.
I'm not sure if what I'm advocating is in tune with others' opinions on the future of LuaTexts, but I am sure something needs to be addressed before it spirals out of control. I'm willing to give up maintainership of LibScriptable if it means someone can pull off a central entity for LuaTexts, while still supporting the various particulars of various addons. Eventually someone needs to take this off my hands anyways, and I'm hoping the community will bite my bait and realize that, hey, there's some advantage to this in-game lower-level UI modification that's worth some healthy attention. Some of you already know this, or you wouldn't be using LuaTexts to begin with.
The more I think about it I guess this may be harmless. It'd probably be a hassle overall, and the future LS is sort of uncertain. Overall I think I'll just log this incident as pure idiocy and move on. ;) Sorry about the intrusion.
I'm having trouble to setup Pitbull Auras like shown in the Picture below: (Exchanging Buffs & Debuffs position depending on friendly or enemy Target)
My first approch was to setup a custom Aura in the Aura Filter Editor to suit my needs: For Testing i 've set up a new AuraFilter using [FONT=Courier New]Display when: Always[/FONT], [FONT=Courier New]Filter type: Meta[/FONT] and [FONT=Courier New]Filter: Buffs AND None[/FONT]
Using this filter for both my Buffs & Debuffs i expected to see buffs on both indicators. But the result was that buffs are still only shown on the buff Indicator. So i guess its not possible to show buffs on the debuff indicator as these are allready filtered out before.
So i came up with the idea that it might be possible to do this within a Lua:Text - exchanging the aura settings of buffs and debuffs in the script. I searched this thread for 'Anchor' but found nothing.
Can someone please give me a hint how/if it possible to change the setting by using Lua:Text?
I've been trying for days to think of a way to do this. What I want to do is hide a value of 0 for my Pitbull Vengeance Text.
local currentVengance = Vengance(unit)
local maxVengance = VenganceMax(unit)
local p = currentVengance / maxVengance * 100
return "%d", currentVengance, p
That's the Vengeance text I use, and I can't figure out anyway to not have it show a value of 0 (It just looks weird sitting at 0 on my bar)
I took out the maxVengeance 'return' since I just want the actual vengeance value
I got this problem, i dont know how to edit lua text. I am a noob at it so i am turing to you here at wowace.
I want to put 2 lua texts in to one.
return '%s %s%s%s',Name(unit),Angle(AFK(unit) or DND(unit))
and this one
local dr,dg,db = DifficultyColor(unit)
local form = DruidForm(unit)
local classification = Classification(unit)
if UnitIsPlayer(unit) or (not UnitIsFriend(unit,"player") and not IsPet(unit)) then
local cr,cg,cb = ClassColor(unit)
return '%s %s%s%s',Name(unit),Angle(AFK(unit) or DND(unit))
if form then
return "%s%s|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r (%s) %s",classification or '',classification and ' ' or '',dr,dg,db,Level(unit),cr,cg,cb,Class(unit),form,SmartRace(unit) or ''
else
return "%s%s|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r %s",classification or '',classification and ' ' or '',dr,dg,db,Level(unit),cr,cg,cb,Class(unit),SmartRace(unit) or ''
end
else
if form then
return "%s%s|cff%02x%02x%02x%s|r (%s) %s",classification or '',classification and ' ' or '',dr,dg,db,Level(unit),form,SmartRace(unit) or ''
else
return "%s%s|cff%02x%02x%02x%s|r %s",classification or '',classification and ' ' or '',dr,dg,db,Level(unit),SmartRace(unit) or ''
end
end
Now it is name at one place on the unitframe and lvl, form and class at a another place.
But i want it to be one line. [lvl] [name] [afk/dnd] [Class] [form] [Race]
Hi there. Just before my WoW subscription ended, I put together a very large LuaText to display multiple auras, with animated timer bars, on PitBull4 unit frames. The bottom line of this image shows the default layout of the text for a resto druid, showing Swiftmend, Wild Growth, Rejuvenation, Regrowth, and Lifebloom. (There are defaults for all classes, both healer-oriented and dps-oriented.)
(click for full size)
The project page (link to wowace) contains a few animations showing the text in action.
If you give this a try, please post your thoughts at the project page.
The LuaText is so huge that it's inconvenient to edit. If several people express interest, I may be able to resubscribe for a bit and restructure the code as an addon you can call from a short LuaText.
I've been trying for days to think of a way to do this. What I want to do is hide a value of 0 for my Pitbull Vengeance Text.
local currentVengance = Vengance(unit)
local maxVengance = VenganceMax(unit)
local p = currentVengance / maxVengance * 100
return "%d", currentVengance, p
That's the Vengeance text I use, and I can't figure out anyway to not have it show a value of 0 (It just looks weird sitting at 0 on my bar)
I took out the maxVengeance 'return' since I just want the actual vengeance value
As this was posted 3 months ago, this probably isn't useful to the original poster... but I don't see an answer given. Just check for 0 and return an empty string (or return nothing at all):
local currentVengance = Vengance(unit)
if ( currentVengance and currentVengance > 0 ) then
return "%d", currentVengance
end
I also removed p since you didn't give it an entry in the format string (so it shouldn't have been doing anything.)
I got this problem, i dont know how to edit lua text. I am a noob at it so i am turing to you here at wowace.
I want to put 2 lua texts in to one
the "return" statement causes execution to stop and the stuff after the return is given to the caller. So by putting a return at the beginning of your text, you're causing it to skip all the following code.
You can either use some temporary strings, or make the four format statements more complicated.
I think you want UnitCastingInfo and UnitChannelInfo. You want your text to listen to UNIT_SPELLCAST_START, UNIT_SPELLCAST_STOP, UNIT_SPELLCAST_CHANNEL_START, and UNIT_SPELLCAST_CHANNEL_STOP
Can someone help me with the code that will basically show the target health but show it in Short format but only class color the "K"? Saw this done in another ui but unable to replicate it.
I'm sure this is probably rather obvious but with my limited skills I can't get it to work.
Thanks for your help.
A simple eclipse display which suggests which main spell to spam based on your eclipse power and buffs:
if select(2, UnitClass("player")) ~= "DRUID" or not PowerBarColor["ECLIPSE"] then
return
end
local form = GetShapeshiftFormID()
if (form and form ~= MOONKIN_FORM) or GetPrimaryTalentTree() ~= 1 then
return
end
local eclipse = UnitPower("player", SPELL_POWER_ECLIPSE)
local buff,_,_,_,_,_,_,_,_,_,_ = UnitAura(PLAYER,"Eclipse (Solar)")
if(buff) then
return "|cff66CD00"..abs(eclipse).." - Wrath!|r"
end
local buff,_,_,_,_,_,_,_,_,_,_ = UnitAura(PLAYER,"Eclipse (Lunar)")
if(buff) then
return "|cff3A5FCD"..abs(eclipse).." - Starfire!|r"
end
if eclipse > 0 then
return "|cff3A5FCD"..abs(eclipse).." - Starfire!|r"
elseif eclipse < 0 then
return "|cff66CD00"..abs(eclipse).." - Wrath!|r"
else
return abs(eclipse).." - Either!|r"
end
A replacement for many indicatiors, because I consider text to be prettier and more distinctive for this than icons. Probably not very efficient.
theString = ''
if UnitAffectingCombat(unit) then
theString = theString.."COMBAT "
end
if UnitIsPVP(unit) then
theString = theString.."PVP "
end
if AFK(unit) then
theString = theString.."AFK "
end
if DND(unit) then
theString = theString.."DND "
end
if Dead(unit) then
theString = theString.."DEAD "
end
if UnitInParty(unit) and UnitIsPartyLeader(unit) then
theString = theString.."PLEAD "
end
if UnitIsPlayer(unit) and UnitInRaid(unit) and IsRaidLeader() then
theString = theString.."RLEAD "
end
if UnitIsPlayer(unit) and UnitInRaid(unit) and IsRaidOfficer() then
theString = theString.."ROFF "
end
if UnitIsPlayer(unit) and IsResting() then
theString = theString.."REST "
end
role = UnitGroupRolesAssigned(unit)
if role == "TANK" then
theString = theString.."TNK "
end
if role == "HEALER" then
theString = theString.."HLR "
end
if role == "DAMAGER" then
theString = theString.."DPS "
end
if UnitIsGhost(unit) then
theString = theString.."GHOST "
end
return theString
A simple raid group display:
if UnitInRaid(unit) then
local size = GetNumRaidMembers()
local uname=Name(unit)
i=1
while i<=size do
local name,_,subgroup = GetRaidRosterInfo(i)
if uname==name then
return "Raid Group: %s", subgroup
end
i=i+1
end
end
So I had a great idea for the Power text on my PitBull unit frames, but I do not really know anything about LUA coding. So, for Hunters, Rogues, and probably Warriors, it's a really big deal not to cap out on power. Under all circumstances you want to do your best to avoid ever actually hitting 100 while raiding.
For this reason, I have my Focus text positioned where I can easily see it and it's big and obvious. However, I was thinking that it would be better if it had some conditions and changed colors according to them.
For example,
if Power < 70 color would be white
if 70 < Power < 90 color would be orange
if Power > 90 color would be red
As you can see, I really don't know how to code this, but I thought I would call out to the community and see if anyone would be interested in throwing this together and sharing. Any advice would also be helpful... maybe someone has already done this, and I just couldn't find it through browsing. Anyway, thanks in advance.
I've moved your post into the existing LuaTexts thread.
I've never used LuaTexts, but you should be able to adapt the following to do what you want, using other working LuaTexts snippets for reference:
local power = UnitPower(unit)
if power > 90 then
return "|cffff0000%d|r", power
elseif power > 70
return "|cffff9900%d|r", power
else
return "|cffffffff%d|r", power
end
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
The second argument you're passing to Power() is rage or mana which isn't defined in the text so it's passing nil, which is the same as passing no 2nd argument at all. The power type is specified by passing an integer that corresponds to the power type.
http://wowprogramming.com/docs/api_types#powerType
However, even replacing the proper constants (mana with SPELL_POWER_MANA and rage with SPELL_POWER_RAGE) won't fix your code because Power() probably returns 0 for the current power type and 0 evaluates to true in Lua.
You should just check the power type directly with UnitPowerType().
E.g. UnitPowerType(unit) == SPELL_POWER_MANA
Thank you for the very fast reply! Works like a charm.
But then I noticed Efflorescence is just an AoE heal with periodic ticks, and does not show up in the bufflist like Wild Growth or Tranquility... So it's not an aura.
There is an addon which checks for people standing in your Efflorescence circle using SPELL_AURA_APPLIED but I can't get that to work either...
Any ideas?
If anyone can see any major flaws in this or can help me understand why certain boss abilities would be inconsistent with my barrens testing results I would appreciate it. Thanks ; )
P.S. the unit ~= "player" part is to prevent what appears to be a bug that occurs when you target yourself and cast a "cast" spell. This bug affects the bar color as well so I know that problem isn't an issue with just my luatext, but I've attempted to work around it by checking to see if the unit is the "player". That's a whole different issue though and I've posted a ticket about it (still pending review)
I'm not sure if what I'm advocating is in tune with others' opinions on the future of LuaTexts, but I am sure something needs to be addressed before it spirals out of control. I'm willing to give up maintainership of LibScriptable if it means someone can pull off a central entity for LuaTexts, while still supporting the various particulars of various addons. Eventually someone needs to take this off my hands anyways, and I'm hoping the community will bite my bait and realize that, hey, there's some advantage to this in-game lower-level UI modification that's worth some healthy attention. Some of you already know this, or you wouldn't be using LuaTexts to begin with.
I'm having trouble to setup Pitbull Auras like shown in the Picture below: (Exchanging Buffs & Debuffs position depending on friendly or enemy Target)
My first approch was to setup a custom Aura in the Aura Filter Editor to suit my needs: For Testing i 've set up a new AuraFilter using [FONT=Courier New]Display when: Always[/FONT], [FONT=Courier New]Filter type: Meta[/FONT] and [FONT=Courier New]Filter: Buffs AND None[/FONT]
Using this filter for both my Buffs & Debuffs i expected to see buffs on both indicators. But the result was that buffs are still only shown on the buff Indicator. So i guess its not possible to show buffs on the debuff indicator as these are allready filtered out before.
So i came up with the idea that it might be possible to do this within a Lua:Text - exchanging the aura settings of buffs and debuffs in the script. I searched this thread for 'Anchor' but found nothing.
Can someone please give me a hint how/if it possible to change the setting by using Lua:Text?
That's the Vengeance text I use, and I can't figure out anyway to not have it show a value of 0 (It just looks weird sitting at 0 on my bar)
I took out the maxVengeance 'return' since I just want the actual vengeance value
I am trying to do something that should be quite simple but not sure how to do it exactly. I have 2 separate LUA texts for %HP and %Power:
return "%s%%",Percent(HP(unit),MaxHP(unit))
and also
return "%s%%",Percent(Power(unit),MaxPower(unit))
All I want to do is round the returned values down to 0 decimal places, so instead of say 82.3% it shows 82%.
After checking the lua texts sticky I think I need to use the function:
Round(number,digits)
But as I said, i'm not sure howto assemble the syntax using my specific lua texts.
Anyone able to help? Thanks.
I got this problem, i dont know how to edit lua text. I am a noob at it so i am turing to you here at wowace.
I want to put 2 lua texts in to one.
and this one
Now it is name at one place on the unitframe and lvl, form and class at a another place.
But i want it to be one line. [lvl] [name] [afk/dnd] [Class] [form] [Race]
ty in advance
(click for full size)
The project page (link to wowace) contains a few animations showing the text in action.
If you give this a try, please post your thoughts at the project page.
The LuaText is so huge that it's inconvenient to edit. If several people express interest, I may be able to resubscribe for a bit and restructure the code as an addon you can call from a short LuaText.
I also removed p since you didn't give it an entry in the format string (so it shouldn't have been doing anything.)
Lots of ways to attack this. But since you want to display an int, I'd do this:
the "return" statement causes execution to stop and the stuff after the return is given to the caller. So by putting a return at the beginning of your text, you're causing it to skip all the following code.
You can either use some temporary strings, or make the four format statements more complicated.
1. Display the target's name while not casting, but have the spell's name replace the target's name when the target casts a spell.
2. Display the target's level while not casting, but have the spell's cast time replace the level text when the target is casting a spell.
Any help would be much appreciated :)
Thank you in advance.
I'm sure this is probably rather obvious but with my limited skills I can't get it to work.
Thanks for your help.
A simple eclipse display which suggests which main spell to spam based on your eclipse power and buffs:
A replacement for many indicatiors, because I consider text to be prettier and more distinctive for this than icons. Probably not very efficient.
A simple raid group display:
For this reason, I have my Focus text positioned where I can easily see it and it's big and obvious. However, I was thinking that it would be better if it had some conditions and changed colors according to them.
For example,
if Power < 70 color would be white
if 70 < Power < 90 color would be orange
if Power > 90 color would be red
As you can see, I really don't know how to code this, but I thought I would call out to the community and see if anyone would be interested in throwing this together and sharing. Any advice would also be helpful... maybe someone has already done this, and I just couldn't find it through browsing. Anyway, thanks in advance.
I've never used LuaTexts, but you should be able to adapt the following to do what you want, using other working LuaTexts snippets for reference: