Elitist Jerks
Register
Blogs
Forums


Go Back   Elitist Jerks » Public Discussion » User Interface and AddOns

Reply
 
LinkBack Thread Tools
Old 08/09/09, 3:07 PM   #151
Methyl
Glass Joe
 
Methyl's Avatar
 
Orc Hunter
 
Illidan
The following LuaText displays one's current Attack Power, Crit%, Armor Pen and Hit Rating.
I've got one tiny issue with this one which I'd appreciate some insight on. I just can't seem to find the appropriate API function call to get one's total Attack Power. At the moment, I'm using "UnitRangedAttackPower("player")" but I've discovered that this call only returns one's base AP and not the total buffed AP. If anyone can shed some light on this one I'd appreciate it.

-- Stats

local ap,cr,arp,hr = UnitRangedAttackPower("player"), GetRangedCritChance(), GetCombatRating(25), GetCombatRating(7)
return "|cff94C7FAAP:%.0f \nCr:%.2f%% \nArP:%.0f HR:%.0f|r", ap,cr,arp,hr
I have been messing with this and i found that the UnitRangedAttackPower() out puts into an array and the way you are calling it you are only captures the 1st argument of said array.
--Stats

local base, posBuff, negBuff = UnitRangedAttackPower("player");
local ap = base + posBuff + negBuff;
local cr,arp,hr = GetRangedCritChance(), GetCombatRating(25), GetCombatRating(7)
return "|cff94C7FAAP:%.0f \nCr:%.2f%% \nArP:%.0f HR:%.0f|r", ap,cr,arp,hr
This one is what you are looking for in terms of adding someones total Ranged AP.

Offline
Reply With Quote
Old 08/09/09, 6:44 PM   #152
Stukka
Glass Joe
 
Stukka
Human Warrior
 
Winterhoof
Originally Posted by the SNEEP View Post
Oh, that's as easy. I'm guessing you want them as separate texts?

Health:
return "%s | %s",Short(HP(unit),true),Short(MaxHP(unit),true)
Power:
if MaxPower(unit) > 0 then
return "%s | %s",Short(Power(unit),true),Short(MaxPower(unit),true)
end


That didn't quite work as i mentioned here is how it shows up my health text is on the right side in the blank bar area. For some reason they way you said to do it doesn't show it as 5.4k | 5.4k. I would like it to be shown that way not 5469 | 5469. Ive tried everything and i can't figure it out what you showed doesn't seem to work? Thanks

this is how i would like it to look:


Last edited by Stukka : 08/09/09 at 6:59 PM.

Offline
Reply With Quote
Old 08/10/09, 11:57 PM   #153
Ohi
Piston Honda
 
Ohi's Avatar
 
Blood Elf Mage
 
Thunderlord
Did a search, but didn't see anything in regard to this, so here goes.

I know with dogtags the following code will show ALL druid rejuv's. Is it possible with the new LUA text to show only your rejuvs (as well as lifebloom, etc.)?

[if HasAura('Rejuvenation') and (AuraDuration('Rejuvenation') >= 5) then 
   AuraDuration('Rejuvenation'):Floor:Green
elseif HasAura('Rejuvenation') and (AuraDuration('Rejuvenation') >= 0) then 
   AuraDuration('Rejuvenation'):Truncate(2,nil):Red
elseif HasAura('Rejuvenation') then 
'swiftmendable'
else ' '
end]

Offline
Reply With Quote
Old 08/11/09, 1:51 AM   #154
Hotan
Piston Honda
 
Hotan's Avatar
 
Gnome Mage
 
Dark Iron
Originally Posted by Ohi View Post
Did a search, but didn't see anything in regard to this, so here goes.

I know with dogtags the following code will show ALL druid rejuv's. Is it possible with the new LUA text to show only your rejuvs (as well as lifebloom, etc.)?

[if HasAura('Rejuvenation') and (AuraDuration('Rejuvenation') >= 5) then 
   AuraDuration('Rejuvenation'):Floor:Green
elseif HasAura('Rejuvenation') and (AuraDuration('Rejuvenation') >= 0) then 
   AuraDuration('Rejuvenation'):Truncate(2,nil):Red
elseif HasAura('Rejuvenation') then 
'swiftmendable'
else ' '
end]
I didn't include your 'swiftmendable' portion because I don't see how it is possible for that display to occur.
local i = 1
while true do
 local name,_,_,_,_,_,expires,caster = UnitAura(unit,i,"HELPFUL")
 if not name then
   break
 elseif name == "Rejuvination" and caster == "player" then
  local rem = GetTime() - expires
  if rem > 5 then
   local r,g,b = 0,255,0
  else
   local r,g,b = 255,0,0
  end
  return "|cff%02x%02x%02x%.1f|r",r,g,b,rem
  break
 end
 i=i+1
end

Last edited by Hotan : 08/11/09 at 1:25 PM. Reason: i=i+1

correlation =/= causation

Offline
Reply With Quote
Old 08/14/09, 10:14 AM   #155
Ferretmonger
Glass Joe
 
Ferretmonger's Avatar
 
Blood Elf Hunter
 
Zenedar (EU)
Originally Posted by Methyl View Post
I have been messing with this and i found that the UnitRangedAttackPower() out puts into an array and the way you are calling it you are only captures the 1st argument of said array.
--Stats

local base, posBuff, negBuff = UnitRangedAttackPower("player");
local ap = base + posBuff + negBuff;
local cr,arp,hr = GetRangedCritChance(), GetCombatRating(25), GetCombatRating(7)
return "|cff94C7FAAP:%.0f \nCr:%.2f%% \nArP:%.0f HR:%.0f|r", ap,cr,arp,hr
This one is what you are looking for in terms of adding someones total Ranged AP.
Thank you very much for the help, thought no one was gonna answer my question ^_^

Offline
Reply With Quote
Old 08/18/09, 1:25 PM   #156
fairkitty
Glass Joe
 
fairkitty's Avatar
 
Human Priest
 
<TM>
Dreadmaul
LuaTexts and Ownbuffs

I have noticed that there is nothing describing how to differentiate between buffs applied by yourself to those applied by other people.

I know that there is support for it in the wow interface but I am not sure on how to do this with the LuaTexts in PB4 (or if you can at all) and I have no experience with the new LuaTexts.

If anyone can give me any help in how to do it id greatly appreciate it.

Offline
Reply With Quote
Old 08/18/09, 3:49 PM   #157
Hamsda
Piston Honda
 
Hamsda's Avatar
 
Goblin Priest
 
Mannoroth (EU)
If you have a look at the API UnitAura at wowwiki, you'll see that it returns

unitCaster
String - unitId reference to the unit that casted the buff/debuff.
which you can compare to "player" to check if you casted a specific debuff.

Hope this helps!



Edit to avoid doublepost:
I have a problem with my % health display for my target.
local s = Status(unit)
if s then
  return s
end
local cur, max = HP(unit), MaxHP(unit)
local miss = cur - max 
if miss ~= 0 then
  if UnitIsFriend(unit,'player') then
    return "|cffff7f7f%s|r\124%s\124%s%%",Short(miss,true),Short(max,true),Round(Percent(cur,max),0)
  else
    return "%s/%s\124%s%%",Short(cur,true),Short(max,true),Round(Percent(cur,max),0)
  end
else
  return max
end
When the target gets to low %, I think it's either 5% or 0.5% (can't pay that much attention to it when fighting mobs with larger hp as a tank or healer), the % display kinda buggs out and looks like this:

Could someone explain me why this happens and how to fix it?

I experimented a bit more with the raptors and got the % display to vanish completely, leaving it with "33/800" or something like that for their hp. I'm getting really confused, but apparently I didn't understand the Round function fully.

Last edited by Hamsda : 08/18/09 at 4:20 PM.

There are only 10 types of people... those who understand binary and those who don't.

Germany Offline
Reply With Quote
Old 08/18/09, 5:47 PM   #158
Hotan
Piston Honda
 
Hotan's Avatar
 
Gnome Mage
 
Dark Iron
@Hamsda: can you explain what this is supposed to return, I can't quite tell. The "\124" is foreign to me.

Originally Posted by fairkitty View Post
I have noticed that there is nothing describing how to differentiate between buffs applied by yourself to those applied by other people.

I know that there is support for it in the wow interface but I am not sure on how to do this with the LuaTexts in PB4 (or if you can at all) and I have no experience with the new LuaTexts.

If anyone can give me any help in how to do it id greatly appreciate it.
I can't give you too concrete of an example, but I can give the function and variable saving method to use.
local name,_,icon,_,_,_,_,caster = UnitAura(unit,i,"HARMFUL")
Replace "HARMFUL" with "HELPFUL" if you are looking for buffs. this is best (well really only) used in a loop (while is preferable)

Here is an example that shows the time left on Rejuv, with different colors based on the amount of time left:
local i = 1
while true do
 local name,_,icon,_,_,_,expires,caster = UnitAura(unit,i,"HELPFUL")
 if not name then
   break
 elseif name == "Rejuvination" and caster == "player" then
  UpdateIn(.1)
  local rem = GetTime() - expires
  if rem > 5 then
   local r,g,b = 0,255,0
  else
   local r,g,b = 255,0,0
  end
  return "|cff%02x%02x%02x%.1f|r",r,g,b,rem
  break
 end
 i=i+1
end
This example is fairly specified since I also was grabbing duration data from the UnitAura() call.

The return to caster will be a UnitID.

Last edited by Hotan : 08/20/09 at 1:16 AM. Reason: UpdateIn()

correlation =/= causation

Offline
Reply With Quote
Old 08/18/09, 7:39 PM   #159
Hamsda
Piston Honda
 
Hamsda's Avatar
 
Goblin Priest
 
Mannoroth (EU)
Originally Posted by Hotan View Post
@Hamsda: can you explain what this is supposed to return, I can't quite tell. The "\124" is foreign to me.
Sorry, forgot that^^ Should've posted a screen when it's working (basically everytime except for low%) :X

Already in bed with my laptop so no screen but I hope a short description will be enough.

\124 is just the escape sequence for "|"^^

For friendly units it looks like:
-3850|38,5k|90%
For enemies it's only:
1234/2468|50%
The missing hp on friendly targets displayed in a light red. I didn't test the behaviour on low% friendly targets but since it's the same return string, it should be the same problem...

Any help is greatly appreciated!


Edit: After seeing your luatext for Reju I got another question^^
A few hours ago I tried to put a simple tag on my target which shows the number of Blood Corruption stacks I have on it and it's time until expiration. The count was no problem but I couldn't get the expiration time to show correctly. Could you explain the logic behind GetTime() - expires from the UnitAura because I don't get it.
Thanks in advance.

There are only 10 types of people... those who understand binary and those who don't.

Germany Offline
Reply With Quote
Old 08/18/09, 8:10 PM   #160
Hotan
Piston Honda
 
Hotan's Avatar
 
Gnome Mage
 
Dark Iron
Hamsda: You are better off using "||" than "\124" if for nothing else than readability.

I changed your way of rounding the Percent. %d rather than %s causes the output to be an interger, thus rounding it for you. I am actually unsure what is causing your return issue, but I do know that Round() isn't actually a lua function, so avoiding it is a good thing. Using Floor(x+.5) will cause the exact same result, but actually use lua functions.
local s = Status(unit)
if s then
  return s
end
local cur, max = HP(unit), MaxHP(unit)
local miss = cur - max 
if miss ~= 0 then
  if UnitIsFriend(unit,'player') then
    return "|cffff7f7f-%s|r||%s||%d%%",Short(miss,true),Short(max,true),Percent(cur,max)
  else
    return "%s/%s||%d%%",Short(cur,true),Short(max,true),Percent(cur,max)
  end
else
  return max
end
In a completely different line of thought, I like to remove the status and put that in a different tag; but that is a personal preference. I just don't want different status returns to hide the health return. This is a rare issue, mostly with friendly targets.

Remaining time stuff:
The return for expires in UnitAura() is a time measured as the time between when your computer was turned on and the time the aura will fade. GetTime() is the time measured between when your computer was turned on and right now. So, expires - GetTime() is the time remaining on the aura.
This would do the display you want, I got rid of the color since I am not sure if you wanted it, but it seems like you have the understanding to add it back in if I am incorrect. %.1f makes the time remaining display as a number with one decimal point (another method of rounding that you can use without lua functions at all)
local i = 1
while true do
 local name,_,_,count,_,_,expires,caster = UnitAura(unit,i,"HELPFUL")
 if not name then
   break
 elseif name == "Blood Corruption" and caster == "player" then
  UpdateIn(.1)
  local rem = expires - GetTime()
  return "%d||%.1f",count,rem
 end
 i=i+1
end

Last edited by Hotan : 08/20/09 at 1:19 AM. Reason: UpdateIn()

correlation =/= causation

Offline
Reply With Quote
Old 08/18/09, 8:33 PM   #161
Hamsda
Piston Honda
 
Hamsda's Avatar
 
Goblin Priest
 
Mannoroth (EU)
Thank you very much Hotan, I'll test your "improved" texts tomorrow and see if there are any errors left

Regarding the \124: I read on a page where I got my basic lua knowledge that this was a better way of handling escape sequences (can't remember why...) but if there is no disadvantage I'll gladly switch to using "||" instead because it is indeed better for reading the code.


Edit:
The health text works like a charm but the Blood Corruption text resulted in an error.
I had to remove the break in the 2nd if conditional and now it works

One question though: rem doesn't update, only if I refresh the Blood Corruption stack so it will always show as 15.0... I thought Unit_Aura would be enough for the text to update properly but apparently I have to activate something else but I don't know what

Last edited by Hamsda : 08/19/09 at 1:20 PM.

There are only 10 types of people... those who understand binary and those who don't.

Germany Offline
Reply With Quote
Old 08/19/09, 9:03 PM   #162
ShadowEric
Piston Honda
 
Human Rogue
 
Terenas
Well if you have UNIT_AURA set as the event for this luatext and you try it solo, it will only run this code when a unit_aura event fires, which is only when a (de)buff changes. So that's why it will only refresh your text when you refresh your debuff, which fires the event.

Of course, in a raid, this will happen a lot more often and it will appear to refresh more often. In any case, for a stable timer, you want more than just unit_aura. I'm not sure you should be using luatext for timers anyway.

Offline
Reply With Quote
Old 08/19/09, 10:54 PM   #163
Hamsda
Piston Honda
 
Hamsda's Avatar
 
Goblin Priest
 
Mannoroth (EU)
I realized this when testing a bit with Thyrm today. Adding the 2 unithealth events helped to refresh when solo but I'll prolly stick just with a stack display and my timer from Quartz.

Thanks for the help anyways

There are only 10 types of people... those who understand binary and those who don't.

Germany Offline
Reply With Quote
Old 08/20/09, 1:13 AM   #164
Hotan
Piston Honda
 
Hotan's Avatar
 
Gnome Mage
 
Dark Iron
Adding Unit_Health would technically work, but that is going to probably result in extra calls, and they will spike or lull depending on the situation.

You could add UpdateIn(x) where x is a number of seconds (or partial seconds). You would want to put this line just after the elseif, that way the Updates only happen if the buff is up there (UnitAura will happily begin the cycle for you)

PS: The UpdateIn() would probably be a good idea in the rejuv thing I posted also, I'll toss it in both.

edit: I'm not sure the error issue. Removing the break isn't a bad thing, it just results in extra UnitAura() calls since you will loop through every debuff rather than stopping when the relevant one is found.

Last edited by Hotan : 08/20/09 at 1:19 AM.

correlation =/= causation

Offline
Reply With Quote
Old 08/20/09, 5:19 AM   #165
fairkitty
Glass Joe
 
fairkitty's Avatar
 
Human Priest
 
<TM>
Dreadmaul
I tried the code today, It worked great I can see only my own buffs. Thankyou for your help

Offline
Reply With Quote
Reply

Go Back   Elitist Jerks » Public Discussion » User Interface and AddOns

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
The DogTags 3.0 Thread Trouble User Interface and AddOns 635 01/29/13 1:44 PM
[DogTags] - Share yours! Fulnir User Interface and AddOns 164 03/30/08 1:30 AM