 |
06/30/09, 5:09 PM
|
#106
|
|
Von Kaiser
|
Originally Posted by Gorsgo
When I called Short(min) without the second parameter it displayed the format (%.1f) instead of the value.
|
Right because of the way Lua handles multiple returns in a list:
a,b,foo(),e,f
Let's say foo returns c,d
The above would actually only evaluate to:
a,b,c,e,f
However:
a,b,foo()
would evaulate to a,b,c,d
It's kinda silly and annoying but it's the way Lua is. In retrospect the 2nd parameter to Short should probably have defaulted to true instead of false. But it's kinda late to make that change.
Also any value except false and nil evaluates to true. So Short just did it at though you'd done Short(value,true). But the string you were passing really wasn't do anything itself.
|
Is there any particular advantage to passing the % through as another value rather than concatenating, though?
|
Passing it through produces no garbage. Concatenation produces a new string because of the way Lua handles strings.
a = a .. b
b is not just added onto a but a new string is made that replaces a. The old a has to be garbage collected. C side doesn't have the same issues.
|
|
|
|
|
07/01/09, 10:16 AM
|
#107
|
|
Von Kaiser
|
Works great Shef. No I thinking about a missing buff text. I would like just a simple "A" is Arcane intellect or Arcane Brilliance, or Dalaran Brilliance is missing. And a "FM"on any Mage and Mage only that is missing Focus Magic.
|
|
|
|
|
07/01/09, 2:36 PM
|
#108
|
|
Piston Honda
|
Originally Posted by Dankz
I would like just a simple "A" is Arcane intellect or Arcane Brilliance, or Dalaran Brilliance is missing. And a "FM"on any Mage and Mage only that is missing Focus Magic.
|
local i = 1
local int = false
while true do
local name = UnitAura(unit,i,"HELPFUL")
if not name then
break
elseif name == "Arcane Intellect" then
int = true
break
elseif name == "Arcane Brilliance" then
int = true
break
elseif name == "Dalaran Intellect" then
int = true
break
elseif name == "Dalaran Brilliance" then
int = true
break
end
i=i+1
end
if UnitPowerType(unit) == 0 and not int then
return "A"
end
local class = Class(unit)
if class == "Mage" then
local i=1
local fm = false
while true do
local name = UnitAura(unit,i,"HELPFUL")
if not name then
break
elseif name == "Focus Magic" then
fm = true
end
i=i+1
end
if not fm then
return "FM"
end
end
Last edited by Hotan : 07/02/09 at 2:20 PM.
Reason: reveresed true/false
|
correlation =/= causation
|
|
|
07/01/09, 11:07 PM
|
#109
|
|
Von Kaiser
|
I'm getting the following error with both Texts

<string>:"PitBull4_LuaTexts:Player:Lua: FM":14: 'end' expected (to close 'function' at line 1) near '<eof>'
PitBull4-v4.0.0-beta1\ModuleHandling\TextProviderModule.lua:117: in function `UpdateFrame'
PitBull4-v4.0.0-beta1\ModuleHandling\TextProviderModule.lua:149: in function `ForceTextUpdate'
PitBull4-v4.0.0-beta1\Modules\LuaTexts\LuaTexts.lua:1191: in function <...erface\AddOns\PitBull4\Modules\LuaTexts\LuaTexts.lua:1187>
PitBull4-v4.0.0-beta1\Modules\LuaTexts\LuaTexts.lua:1260: in function <...erface\AddOns\PitBull4\Modules\LuaTexts\LuaTexts.lua:1256>
(tail call): ?:
<in C code>: ?
<string>:"safecall Dispatcher[2]":9: in function <[string "safecall Dispatcher[2]"]:5>
(tail call): ?:
AceConfigDialog-3.0-34:786: in function <...nfig-3.0\AceConfigDialog-3.0\AceConfigDialog-3.0.lua:605>
(tail call): ?:
<in C code>: ?
<string>:"safecall Dispatcher[3]":9: in function <[string "safecall Dispatcher[3]"]:5>
(tail call): ?:
AceGUI-3.0-23 (Ace3):305: in function `Fire'
...AceGUI-3.0\widgets\AceGUIWidget-MultiLineEditBox.lua:76: in function <...AceGUI-3.0\widgets\AceGUIWidget-MultiLineEditBox.lua:73>:
...AceGUI-3.0\widgets\AceGUIWidget-MultiLineEditBox.lua:85: in function <...AceGUI-3.0\widgets\AceGUIWidget-MultiLineEditBox.lua:82>:
|
|
|
|
|
07/02/09, 12:53 AM
|
#110
|
|
Piston Honda
|
Originally Posted by Dankz
I'm getting the following error with both Texts
|
They should both be fixed. I forgot an 'end' at the end of the while loops.
|
correlation =/= causation
|
|
|
07/02/09, 7:34 AM
|
#111
|
|
Von Kaiser
Tauren Druid
Anachronos (EU)
|
Isn't the 1st still missing i = i+1 to increase the counter inside the loop? And the second have no counter at all.
Edit: Assuming it is beginners who ask for help with tags, using int = true to indicate when the buff is missing might be a bit confusing for those who aren't good at reading code.
Last edited by zimira : 07/02/09 at 7:45 AM.
|
|
|
|
|
07/03/09, 11:10 AM
|
#112
|
|
Von Kaiser
|
Originally Posted by zimira
Isn't the 1st still missing i = i+1 to increase the counter inside the loop? And the second have no counter at all.
|
Yes, I'm still having trouble seems to be stuck in a loop and crashes the game.
|
|
|
|
|
07/03/09, 1:23 PM
|
#113
|
|
Piston Honda
|
Originally Posted by Dankz
Yes, I'm still having trouble seems to be stuck in a loop and crashes the game.
|
i=i+1 is in there.
|
correlation =/= causation
|
|
|
07/05/09, 10:56 PM
|
#114
|
|
Glass Joe
Blood Elf Priest
Echo Isles
|
Actually, i'm going to edit this post again because I'm still having issues with an indicator code.
It seemed to work fine this way with DogTags, but once I converted to LuaTexts it's not working properly.
I have indicators to show when Renew, Prayer of Mending, Shield, etc. are on a target in my raid, so I know when to refresh them.. However, when shield fades the indicator fades, even if they still have Weakened Soul (meaning I can't refresh the shield).
This is the code I used at first:
local i = 1
local renew,shield,mending = false,false,false
while true do
local name,_,icon = UnitAura(unit,i,"HELPFUL")
if not name then
break
elseif name == "Power Word: Shield" then
shield = true
elseif name == "Weakened Soul" then
shield = true
elseif name == "Renew" then
renew = true
elseif name == "Prayer of Mending" then
mending = true
end
i = i + 1
end
Outline()
return "%s %s %s",shield and "|cffFFFF00S|r" or '',renew and "|cff00C000R|r" or '',mending and "|cffFFFF00M|r" or ''
This one worked fine except for the Weakened Soul problem.
So I read through this thread more and found the HARMFUL code, and added that in, ending up with this:
local i = 1
local renew,shield,mending = false,false,false
while true do
local name,_,icon = UnitAura(unit,i,"HELPFUL")
if not name then
break
elseif name == "Power Word: Shield" then
shield = true
elseif name == "Renew" then
renew = true
elseif name == "Prayer of Mending" then
mending = true
end
local name,_,icon = UnitAura(unit,i,"HARMFUL")
if not name then
break
elseif name == "Weakened Soul" then
shield = true
end
i = i + 1
end
Outline()
return "%s %s %s",shield and "|cffFFFF00S|r" or '',renew and "|cff00C000R|r" or '',mending and "|cffFFFF00M|r" or ''
This seemed to have done the trick at first, but now it won't show all of the indicators at once if I have all 3 buffs on me.
Can someone tell me what I'm missing, if anything? Or if maybe it's just bugged? Or tell me if this is completely wrong, because Lua frustrates me and i've just been hacking my codes together with copy and paste from this thread.
Last edited by Eyrika : 07/06/09 at 7:01 PM.
Reason: l2read
|
|
|
|
|
07/07/09, 2:17 AM
|
#115
|
|
Von Kaiser
|

Originally Posted by Eyrika
Actually, i'm going to edit this post again because I'm still having issues with an indicator code.
It seemed to work fine this way with DogTags, but once I converted to LuaTexts it's not working properly.
I have indicators to show when Renew, Prayer of Mending, Shield, etc. are on a target in my raid, so I know when to refresh them.. However, when shield fades the indicator fades, even if they still have Weakened Soul (meaning I can't refresh the shield).
This is the code I used at first:
local i = 1
local renew,shield,mending = false,false,false
while true do
local name,_,icon = UnitAura(unit,i,"HELPFUL")
if not name then
break
elseif name == "Power Word: Shield" then
shield = true
elseif name == "Weakened Soul" then
shield = true
elseif name == "Renew" then
renew = true
elseif name == "Prayer of Mending" then
mending = true
end
i = i + 1
end
Outline()
return "%s %s %s",shield and "|cffFFFF00S|r" or '',renew and "|cff00C000R|r" or '',mending and "|cffFFFF00M|r" or ''
This one worked fine except for the Weakened Soul problem.
So I read through this thread more and found the HARMFUL code, and added that in, ending up with this:
local i = 1
local renew,shield,mending = false,false,false
while true do
local name,_,icon = UnitAura(unit,i,"HELPFUL")
if not name then
break
elseif name == "Power Word: Shield" then
shield = true
elseif name == "Renew" then
renew = true
elseif name == "Prayer of Mending" then
mending = true
end
local name,_,icon = UnitAura(unit,i,"HARMFUL")
if not name then
break
elseif name == "Weakened Soul" then
shield = true
end
i = i + 1
end
Outline()
return "%s %s %s",shield and "|cffFFFF00S|r" or '',renew and "|cff00C000R|r" or '',mending and "|cffFFFF00M|r" or ''
This seemed to have done the trick at first, but now it won't show all of the indicators at once if I have all 3 buffs on me.
Can someone tell me what I'm missing, if anything? Or if maybe it's just bugged? Or tell me if this is completely wrong, because Lua frustrates me and i've just been hacking my codes together with copy and paste from this thread.
|
I'd do this:
local i = 1
local renew,shield,mending = false,false,false
while true do
local name,_,icon = UnitAura(unit,i)
if not name then
break
elseif name == "Power Word: Shield" then
shield = true
elseif name == "Weakened Soul" then
shield = true
elseif name == "Renew" then
renew = true
elseif name == "Prayer of Mending" then
mending = true
end
i = i + 1
end
Outline()
return "%s %s %s",shield and "|cffFFFF00S|r" or '',renew and "|cff00C000R|r" or '',mending and "|cffFFFF00M|r" or ''
I just took the filter off your UnitAura call. It should get buffs and debuffs all together. Your version wasn't working right because you were trying to use one loop for both. There might be say 5 HELPFUL auras and 1 debuff. Your version would stop after it got to i = 1 because i = 2 would have no debuff.
Mixing buffs and debuffs should be safe for the purposes of what you're doing. I doubt there's a debuff called Prayer of Mending and so on.
|
|
|
|
|
07/07/09, 8:10 PM
|
#116
|
|
Glass Joe
Blood Elf Priest
Echo Isles
|
Thank you for your suggestion, however it still doesn't appear to work  It's working the same as the first code I tried and not keeping the "S" when I have no shield but still have weakened soul. I'll keep working at it and see if I can find something.
Edit: I tried another code you posted on the first page:
local i = 1
local renew,shield,mending = false,false,false
while true do
local name,_,icon = UnitAura(unit,i,"HELPFUL")
if not name then
break
elseif name == "Power Word: Shield" then
shield = true
elseif name == "Renew" then
renew = true
elseif name == "Prayer of Mending" then
mending = true
end
i = i + 1
end
local i = 1
while true do
local name,_,icon = UnitAura(unit,i,"HARMFUL")
if not name then
break
elseif name == "Weakened Soul" then
shield = true
end
i = i + 1
end
Outline()
return "%s %s %s",shield and "|cffFFFF00S|r" or '',renew and "|cff00C000R|r" or '',mending and "|cffFFFF00M|r" or ''
And so far, it's working right. I think I may have just missed one line somewhere.
Last edited by Eyrika : 07/07/09 at 8:16 PM.
|
|
|
|
|
07/09/09, 4:11 AM
|
#117
|
|
Glass Joe
|
I am currently using the code below for my Lua:Power text. Right now it loos like this:
Current MP | Percent
if UnitPowerType(unit) == 0 then
cur,max=Power(unit),MaxPower(unit)
return "%s | %s%%",cur,Percent(cur,max)
else
cur=Power(unit)
return cur
end
I'd like to color it so it starts out as "mage blue" (my default mana coloring)> yellow>red and I would also like to change the Current MP to short so my tag looks like this 5.6k instead of 5623. So my tag would look like this:
5.6k | 100%
Thank you in advance. I'm sure you get tons and tons of help requests. I truly appreciate your help.
*sidenote* I know nothing about Lua and this is all trial and error. Very satisfying when you figure things out on your own =)
Last edited by Tastie : 07/09/09 at 1:12 PM.
|
|
|
|
|
07/09/09, 2:02 PM
|
#118
|
|
Piston Honda
|
Tastie: I'm not quite sure this is exactly what you want, and you can change the color thresholds if you want.
I also don't quite understand your choice to have the color be Power_Type defined at high levels, this is going to make it unreadable over the bar (we can make it simply not display if that is the goal).
Regarding the non-mana portion, I didn't do anything to it because I didn't see anything you wanted done there.
if UnitPowerType(unit) == 0 then
local cur,max=Power(unit),MaxPower(unit)
local per=Percent(cur,max)
if per>75 then
local r,g,b=PowerColor(UnitPowerType(unit))
return "|cff%02x%02x%02x%s || %s%%|r",r,g,b,Short(cur),per
elseif per>25 then
return "|cffffff00%s || %s%%|r",Short(cur),per
else
return "|cffff0000%s || %s%%|r",Short(cur),per
end
else
cur=Power(unit)
return cur
end
|
correlation =/= causation
|
|
|
07/09/09, 2:34 PM
|
#119
|
|
Glass Joe
|
Originally Posted by Hotan
Tastie: I'm not quite sure this is exactly what you want, and you can change the color thresholds if you want.
I also don't quite understand your choice to have the color be Power_Type defined at high levels, this is going to make it unreadable over the bar (we can make it simply not display if that is the goal).
Regarding the non-mana portion, I didn't do anything to it because I didn't see anything you wanted done there.
if UnitPowerType(unit) == 0 then
local cur,max=Power(unit),MaxPower(unit)
local per=Percent(cur,max)
if per>75 then
local r,g,b=PowerColor(UnitPowerType(unit))
return "|cff%02x%02x%02x%s || %s%%|r",r,g,b,Short(cur),per
elseif per>25 then
return "|cffffff00%s || %s%%|r",Short(cur),per
else
return "|cffff0000%s || %s%%|r",Short(cur),per
end
else
cur=Power(unit)
return cur
end
|
Thinking about it more, maybe color wasn't the way to go. How can I modify my current code:
if UnitPowerType(unit) == 0 then
cur,max=Power(unit),MaxPower(unit)
return "%s | %s%%",cur,Percent(cur,max)
else
cur=Power(unit)
return cur
end
so that it simply looks like:
5.6k | 100%
I've tried adding Short(Power(unit)) but that doesn't seem to be working.
Thanks Hotan for the response.
|
|
|
|
|
07/09/09, 4:53 PM
|
#120
|
|
Piston Honda
|
if UnitPowerType(unit) == 0 then
local cur,max=Power(unit),MaxPower(unit)
return "%s || %s%%",Short(cur),Percent(cur,max)
else
cur=Power(unit)
return cur
end
The problem with defining cur as Short(Power(unit)) is that you use cur to calculate a percent, and Short(##) isn't a number.
|
correlation =/= causation
|
|
|
|