Elitist Jerks
Register
Blogs
Forums


Go Back   Elitist Jerks » User Interface and AddOns

Reply
 
LinkBack Thread Tools
Old 09/06/09, 10:38 AM   #176
Negheos
Glass Joe
 
Night Elf Druid
 
Wrathbringer (EU)
Another idea I´m working on is automatic buffcanceling:

local i = 1
while true do
   local name,_,_,_,_,_,expires,_ = UnitAura("player",i,"HELPFUL")
      if not name then
         break
      elseif name == "AURATOCANCEL" then
         local rem = expires - GetTime()
            if rem<TIMEREMAININGTOCANCEL then
               CancelUnitBuff("player","AURATOCANCEL")
            end
      end
      i=i+1
end
I´m struggling with the OnEvent - for testing I tried
self:RegisterEvent("UNIT_SPELLCAST_START")
(I´m using this with kgpanels). But this will only update the value of "rem" each time a spell is cast. Afterwards "rem" remains constant until a new spell is cast. The idea was to have a certain aura with low time remaining (maybe eclipse) automatically canceled right before a certain spell ends (maybe starfire) so the aura can come up again and the spell receives still a maximum of the auras benefit. Therefore the aura must be canceled at the very end of the spell so a lag induced timeshift between "spell complete" and "aura cancelled" lets the server allow another upcome of the aura.

To clarify: Maybe there are already addons around for this but I´m sure it can be done in simple luatext input I just need an idea how to do the time management without the "UpdateIn(t)" function.

Offline
Reply With Quote
Old 09/17/09, 6:11 AM   #177
Fanto
Glass Joe
 
Dwarf Paladin
 
Thrall (EU)
Originally Posted by ctrlfrk View Post
Here is a small Luatext to show how far away the unit is from you:

local rc = LibStub("LibRangeCheck-2.0")
local minRange, maxRange = rc:getRange(unit)
UpdateIn(1.0)
return "|cff404040%s",  tostring(maxRange or "Far")

You may need to install LibRangeCheck for it to work.
Has anyone got this code to work with the new version of PB (>beta5)? I just updated PB, so I think no other addon may cause the following error (librangecheck-2-0 is located in the Interface folder) :

[2009/09/16 00:42:40-3431-x1]: <string>:"PitBull4_LuaTexts:Target:range":1: Cannot find a library instance of "LibRangeCheck-2.0". 
PitBull4_LuaTexts-v4.0.0-beta5\LuaTexts.lua:1153: in function `AddFontString' 
PitBull4-v4.0.0-beta5\ModuleHandling\TextProviderModule.lua:118: in function `UpdateFrame' 
PitBull4-v4.0.0-beta5\ModuleHandling\Module.lua:319: in function `Update' 
PitBull4-v4.0.0-beta5\UnitFrame.lua:636: in function `Update' 
PitBull4-v4.0.0-beta5\UnitFrame.lua:662: in function `UpdateGUID' 
PitBull4-v4.0.0-beta5\Main.lua:1330: in function `CheckGUIDForUnitID' 
PitBull4-v4.0.0-beta5\Main.lua:1341: in function `?' 
CallbackHandler-1.0-3:146: in function <non> 
<string>:"safecall Dispatcher[1]":4: in function <string> 
<in>: ? 
<string>:"safecall Dispatcher[1]":13: in function `?' 
CallbackHandler-1.0-3:91: in function `Fire' 
AceEvent-3.0-3 (Bagnon):119: in function <ace> 
<in>: in function `TargetUnit' 
Interface\FrameXML\SecureTemplates.lua:379: in function `handler': 
Interface\FrameXML\SecureTemplates.lua:487: in function `SecureActionButton_OnClick': 
Interface\FrameXML\SecureTemplates.lua:528: in function <Interface>:
EDIT: Problem is solved if the LibRange is copied into the Libs Folder of PB4 and one includes the lib manually by editing the libs.xml. Not very comfortable but it works..

Last edited by Fanto : 09/17/09 at 11:41 AM.

Offline
Reply With Quote
Old 10/15/09, 11:51 AM   #178
mareri
Glass Joe
 
Night Elf Druid
 
Sargeras
Druid Hot Text

I was hoping someone would be able to help me. This is what I'm trying to do.

Show a countdown of each of the hot spells that I cast on a unit. The countdown should be in a specific color to indicate which spell it is.

I know very little about LUA and have attempted to get something working by looking at examples in this forum and other forums. Below are my attempts. They either show an error or the duration doesn't display correctly and doesn't count down. I've only coded my examples for rejuvenation until I know that spell is working. I add the text to LUA text for pitbull; I don't change any other settings except for I set the event to UNIT_AURA. Is there anything other event I should use? Anything else I need to do to make sure it works correctly? What is the best way to code what I want to do? Where am I going wrong in my examples?

Thank you so much for your time and help!

Attempt #1 (would have to update all the spells to be like rejuvenation)
local text = ""
Outline()

 local name,_,icon,_,_,_,expires,caster = UnitAura(unit,"Rejuvination")
 if name == "Rejuvination" and caster == "player" then
  UpdateIn(.1)
  local rem = GetTime() - expires
  text = text .. format("|cffff0000%s|r[%d]", rem)
 end
 
if UnitAura(unit, "Regrowth") ~= nil then
text = text .. format("|cff00ff00%s|r","R")
end

if UnitAura(unit, "Wild Growth") ~= nil then
text = text .. format("|cffffff00%s|r","WG")
end

if UnitAura(unit, "Lifebloom") ~= nil then
_,_,_,count = UnitAura(unit, "Lifebloom")
text = text .. format("|cffffff00%s|r[%d]","LB",count)
end

return text
Attempt #2 (would have to create an elseif for each spell)
 local text = ""
 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
  text = text .. format("|cffff0000%s|r[%d]", rem)
  break
 end
 i=i+1
end

Offline
Reply With Quote
Old 10/15/09, 1:21 PM   #179
ShadowEric
Piston Honda
 
Human Rogue
 
Terenas
I can't help you much because I'm not home right now, but you've misspelled RejuvEnation (look at the letter I've capitalized).

Offline
Reply With Quote
Old 10/23/09, 3:00 AM   #180
Katassta
Glass Joe
 
Draenei Hunter
 
Blackhand
Originally Posted by Fanto View Post
Has anyone got this code to work with the new version of PB (>beta5)? I just updated PB, so I think no other addon may cause the following error (librangecheck-2-0 is located in the Interface folder) :

.......

EDIT: Problem is solved if the LibRange is copied into the Libs Folder of PB4 and one includes the lib manually by editing the libs.xml. Not very comfortable but it works..
Is there a way to get the range check to work without changing the PB4 libs.xml?

I don't like having to fix it every time I update the addon.

Offline
Reply With Quote
Old 10/27/09, 8:41 AM   #181
Fanto
Glass Joe
 
Dwarf Paladin
 
Thrall (EU)
Originally Posted by Katassta View Post
Is there a way to get the range check to work without changing the PB4 libs.xml?

I don't like having to fix it every time I update the addon.
Another solution was posted a couple of weeks ago in the WowAce Forums - View Single Post - LuaTexts Official Thread

Offline
Reply With Quote
Old 11/04/09, 6:51 PM   #182
Ich
Glass Joe
 
Night Elf Hunter
 
Laughing Skull
I am in need of some assistance. Im using pitbull 4 with the targets cast bars enabled. I want the Lua:Class to be located on the cast bar, but I want the class text to disappear when the target begins to cast and reappear when they are finished casting/its interrupted. Ive looked in alot of places to no avail. Could anyone point me in the right direction? Thanks

Edit: Nvm I got it
I added in this little bit of code to the Lua:Class code sequence:

local casting = CastData(unit)
if casting then
return
else
//random stuff involving class info
end

Last edited by Ich : 11/04/09 at 7:05 PM.

Offline
Reply With Quote
Old 11/20/09, 7:09 PM   #183
Eurytos
Piston Honda
 
Eurytos's Avatar
 
Orc Hunter
 
Zul'Jin
Wow... I am so lost with this new syntax. Here's what I want to do for my target's power text in a nutshell:

If unit isNPC then
threatpercent
else
currentPower "/" maxPower
end

Can anyone help me out with this?

Offline
Reply With Quote
Old 11/22/09, 7:27 PM   #184
henrik_s
Glass Joe
 
henrik_s's Avatar
 
Blood Elf Priest
 
Tarren Mill (EU)
Try this:

local _, _, _, threat, _ = UnitDetailedThreatSituation("player", unit)
local curPower, maxPower = UnitPower(unit), UnitPowerMax(unit)

if UnitIsPlayer(unit) == nil then
return threat
else
return "%s / %s",curPower,MaxPower
end
This shows your threat percentage relative to the target's target (you pull aggro at 110%/130%). If you want the value scaled (pulling at 100%) use the following instead:

local _, _, threat, _, _ = UnitDetailedThreatSituation("player", unit)

Last edited by henrik_s : 11/22/09 at 7:46 PM.

Too cool for holy school.

Offline
Reply With Quote
Old 11/30/09, 2:44 PM   #185
Laraque
Glass Joe
 
Draenei Death Knight
 
Silver Hand
This is what I use to show lifebloom stacks:
local _, _, _, nLBStacks, _, _, _, caster, _= UnitAura(unit,"Lifebloom")
if nLBStacks and caster == "player" then
return "%d", nLBStacks
end
How much time is left on Rejuvination:
local _, _, _, _, _, _, expires, caster, _ = UnitAura(unit,"Rejuvenation")
if caster == "player" then
local rem = - (GetTime() - expires)
UpdateIn(0.25)
return "|cffff00ff%d|r", rem
end
If the person in the raid/group has Gift of the Wild:
local i = 1
local int = true
while true do
local name, _, _, _, _, _, _, _, _ = UnitAura(unit,i)
if not name then
break
elseif name == "Gift of the Wild" then
int = false
break
elseif name == "Mark of the Wild" then
int = false
break
end
i = i + 1
end
if int then
return "|cff8A2BE2%s|r",X
end

Offline
Reply With Quote
Old 12/01/09, 8:12 AM   #186
Zeelian
Glass Joe
 
Zeelian's Avatar
 
Night Elf Priest
 
Azjol-Nerub (EU)
Would it be possible to modify this snippet of code to color the text based on how many stacks the person has?

if UnitAura(unit,"Acid-Drenched Mandibles",nil,"HARMFUL") then
  local _,_,_,count,_,_,_,_,_ = UnitAura(unit,"Acid-Drenched Mandibles",nil,"HARMFUL")
  return count
end
1-2-3 Green
4-5-6 Yellow
7-8-9 Orange
10+ Red

Offline
Reply With Quote
Old 12/01/09, 3:48 PM   #187
Laraque
Glass Joe
 
Draenei Death Knight
 
Silver Hand
Originally Posted by Zeelian View Post
Would it be possible to modify this snippet of code to color the text based on how many stacks the person has?

if UnitAura(unit,"Acid-Drenched Mandibles",nil,"HARMFUL") then
  local _,_,_,count,_,_,_,_,_ = UnitAura(unit,"Acid-Drenched Mandibles",nil,"HARMFUL")
  return count
end
1-2-3 Green
4-5-6 Yellow
7-8-9 Orange
10+ Red
What does adding the filter "nil" to UnitAura do for you?

But for color you can replace your simple "return" command with something like:

  If count < 4
    return "|cff00ff00%d|r", count
  end
  If count > 3 and count < 7
    return "|cffffff00%d|r", count
  end
  If count > 6 and count <10
    return "|cffffa500%d|r", count
  end
  If count > 10
    return "|cffff0000%d|r", count
  end

Offline
Reply With Quote
Old 12/03/09, 10:04 PM   #188
Zeelian
Glass Joe
 
Zeelian's Avatar
 
Night Elf Priest
 
Azjol-Nerub (EU)
Originally Posted by Laraque View Post
What does adding the filter "nil" to UnitAura do for you?

But for color you can replace your simple "return" command with something like:

  If count < 4
    return "|cff00ff00%d|r", count
  end
  If count > 3 and count < 7
    return "|cffffff00%d|r", count
  end
  If count > 6 and count <10
    return "|cffffa500%d|r", count
  end
  If count > 10
    return "|cffff0000%d|r", count
  end
Honestly i have no idea, i'm using a plain and simply "stolen" code that was originally used for lifebloom that i edited for the mandible debuff.

I will give this a test tomorrow on Anub, thanks a mil for the help.

Offline
Reply With Quote
Old 12/06/09, 2:48 PM   #189
Zeelian
Glass Joe
 
Zeelian's Avatar
 
Night Elf Priest
 
Azjol-Nerub (EU)
Originally Posted by Laraque View Post
What does adding the filter "nil" to UnitAura do for you?

But for color you can replace your simple "return" command with something like:

  If count < 4
    return "|cff00ff00%d|r", count
  end
  If count > 3 and count < 7
    return "|cffffff00%d|r", count
  end
  If count > 6 and count <10
    return "|cffffa500%d|r", count
  end
  If count > 10
    return "|cffff0000%d|r", count
  end
I have tested adding that code into the code i use making it:

if UnitAura(unit,"Acid-Drenched Mandibles",nil,"HARMFUL") then
  local _,_,_,count,_,_,_,_,_ = UnitAura(unit,"Acid-Drenched Mandibles",nil,"HARMFUL")
    If count < 4
    return "|cff00ff00%d|r", count
  end
  If count > 3 and count < 7
    return "|cffffff00%d|r", count
  end
  If count > 6 and count <10
    return "|cffffa500%d|r", count
  end
  If count > 10
    return "|cffff0000%d|r", count
  end
end
but getting {err} with a log of:

22x <string>:"PitBull4_LuaTexts:Raid:Lua: Stack 1":3: '=' expected near 'count'
PitBull4-v4.0.0-beta5-23-ge4c6b5b\ModuleHandling\TextProviderModule.lua:118: in function `UpdateFrame'
PitBull4-v4.0.0-beta5-23-ge4c6b5b\ModuleHandling\TextProviderModule.lua:150: in function `ForceTextUpdate'
PitBull4_LuaTexts-v4.0.0-beta5-23-ge4c6b5b\LuaTexts.lua:1225: in function <PitBull4_LuaTexts\LuaTexts.lua:1221>
PitBull4_LuaTexts-v4.0.0-beta5-23-ge4c6b5b\LuaTexts.lua:1295: in function <PitBull4_LuaTexts\LuaTexts.lua:1291>
(tail call): ?:
<in C code>: ?
<string>:"safecall Dispatcher[2]":9: in function <[string "safecall Dispatcher[2]"]:5>
(tail call): ?:
AceConfigDialog-3.0-38:799: in function <...nfig-3.0\AceConfigDialog-3.0\AceConfigDialog-3.0.lua:614>

Offline
Reply With Quote
Old 12/06/09, 7:26 PM   #190
ctrlfrk
Glass Joe
 
Orc Hunter
 
Firetree
"If" statements require a "then" at the end of the condition; try this:

if UnitAura(unit,"Acid-Drenched Mandibles",nil,"HARMFUL") then
  local _,_,_,count,_,_,_,_,_ = UnitAura(unit,"Acid-Drenched Mandibles",nil,"HARMFUL")
  if count < 4 then
    return "|cff00ff00%d|r", count
  end
  if count > 3 and count < 7 then
    return "|cffffff00%d|r", count
  end
  if count > 6 and count <10 then
    return "|cffffa500%d|r", count
  end
  if count > 10 then
    return "|cffff0000%d|r", count
  end
end

Offline
Reply With Quote
Old 12/07/09, 3:29 PM   #191
Zeelian
Glass Joe
 
Zeelian's Avatar
 
Night Elf Priest
 
Azjol-Nerub (EU)
Originally Posted by ctrlfrk View Post
"If" statements require a "then" at the end of the condition; try this:

if UnitAura(unit,"Acid-Drenched Mandibles",nil,"HARMFUL") then
  local _,_,_,count,_,_,_,_,_ = UnitAura(unit,"Acid-Drenched Mandibles",nil,"HARMFUL")
  if count < 4 then
    return "|cff00ff00%d|r", count
  end
  if count > 3 and count < 7 then
    return "|cffffff00%d|r", count
  end
  if count > 6 and count <10 then
    return "|cffffa500%d|r", count
  end
  if count > 10 then
    return "|cffff0000%d|r", count
  end
end
Heh, figures it would be something stupidly simple that was missing, no errors popping, now i just hope it works.


Another question reguarding the anub fight.

I use

local s = Status(unit)
if s then
  return s
end
local cur, max = HP(unit), MaxHP(unit)
if UnitIsFriend(unit,"player") then
  local miss = max - cur 
  if miss ~= 0 then
    return "-%d",miss
  else
    return VeryShort(max)
  end
end
För HP on my raidframes, how would i go about to make this text turn orange if the person has less then 6k HP and red if they have less then 300 hp.

figured as much as i have to add another layer of if's

Not sure if this is correct:

replace

  if miss ~= 0 then
    return "-%d",miss
with (the "-%d" might be wrong aswell since im not sure how to add it into the code)

  if miss ~= 0 then
 if cur <300  then 
  return "|cffff0000-%d|r", miss
 end
 if cur > 300 and cur < 6000 then
  return "|cffffa500-%d|r", miss
end
making the total code into:

local s = Status(unit)
if s then
  return s
end
local cur, max = HP(unit), MaxHP(unit)
if UnitIsFriend(unit,"player") then
  local miss = max - cur 
 if miss ~= 0 then
  if cur <300  then 
   return "|cffff0000-%d|r", miss
  end
  if cur > 300 and cur < 6000 then
   return "|cffffa500-%d|r", miss
  end
  else
      return "-%d",miss
   end
  else
    return VeryShort(max)
  end
end

I have messed something up with this code, but im not sure what.

Its propable something with the

else
return "-%d",miss
end

part

Last edited by Zeelian : 12/07/09 at 3:44 PM.

Offline
Reply With Quote
Old 12/07/09, 8:34 PM   #192
zimira
Von Kaiser
 
Tauren Druid
 
Anachronos (EU)
Not sure if you missed an "end" in your code. Cleaning up your code, i got this i think you where aiming for?

local s = Status(unit)
if s then
  return s
end
local cur, max = HP(unit), MaxHP(unit)
if UnitIsFriend(unit,"player") then
  local miss = max - cur 
  if miss ~= 0 then
    if cur <300  then 
      return "|cffff0000-%d|r", miss
    elseif cur < 6000 then
      return "|cffffa500-%d|r", miss
    else
      return "-%d",miss
    end
  else
    return VeryShort(max)
  end
end

Offline
Reply With Quote
Old 12/07/09, 11:52 PM   #193
Zeelian
Glass Joe
 
Zeelian's Avatar
 
Night Elf Priest
 
Azjol-Nerub (EU)
Originally Posted by zimira View Post
Not sure if you missed an "end" in your code. Cleaning up your code, i got this i think you where aiming for?

local s = Status(unit)
if s then
  return s
end
local cur, max = HP(unit), MaxHP(unit)
if UnitIsFriend(unit,"player") then
  local miss = max - cur 
  if miss ~= 0 then
    if cur <300  then 
      return "|cffff0000-%d|r", miss
    elseif cur < 6000 then
      return "|cffffa500-%d|r", miss
    else
      return "-%d",miss
    end
  else
    return VeryShort(max)
  end
end
Thanks ill give that a test next run at anub and see if it works better then my own crude attempt at it. I still have a long way to go with the lua coding thou i am starting to get the hang of the basics.

Offline
Reply With Quote
Old 12/10/09, 11:38 AM   #194
Shot
Glass Joe
 
Human Priest
 
Emerald Dream (EU)
For the new LFG system, since a lot of unit frame addons don't have any indicators yet..

local isTank, isHealer, isDamage = UnitGroupRolesAssigned(unit);
if ( isTank ) then
    return "Tank";
elseif ( isHealer ) then
    return "Healer";
elseif ( isDamage ) then
    return "DPS";
end
For example with Pitbull, create a new text, paste that in - done!

Offline
Reply With Quote
Old 12/16/09, 2:42 AM   #195
Eurytos
Piston Honda
 
Eurytos's Avatar
 
Orc Hunter
 
Zul'Jin
Originally Posted by henrik_s View Post
Try this:

local _, _, _, threat, _ = UnitDetailedThreatSituation("player", unit)
local curPower, maxPower = UnitPower(unit), UnitPowerMax(unit)

if UnitIsPlayer(unit) == nil then
return threat
else
return "%s / %s",curPower,MaxPower
end
This shows your threat percentage relative to the target's target (you pull aggro at 110%/130%). If you want the value scaled (pulling at 100%) use the following instead:

local _, _, threat, _, _ = UnitDetailedThreatSituation("player", unit)
That gave me errors. Figured it out though.

if UnitIsPlayer(unit) then
  local max = MaxPower(unit)
  if max > 0 then
    return "%s%%",Percent(Power(unit),max)
  end
  else
  local unit_a,unit_b = ThreatPair(unit)
  if unit_a and unit_b then
    local _,status,percent = UnitDetailedThreatSituation(unit_a, unit_b)
    if percent and percent ~= 0 then
      local r,g,b = ThreatStatusColor(status)
      return "|cff%02x%02x%02x%s%%|r",r,g,b,Round(percent,1)
    end
  end
end
return ConfigMode()

Offline
Reply With Quote
Old 12/17/09, 1:12 AM   #196
Zeelian
Glass Joe
 
Zeelian's Avatar
 
Night Elf Priest
 
Azjol-Nerub (EU)
Originally Posted by Shot View Post
For the new LFG system, since a lot of unit frame addons don't have any indicators yet..

local isTank, isHealer, isDamage = UnitGroupRolesAssigned(unit);
if ( isTank ) then
    return "Tank";
elseif ( isHealer ) then
    return "Healer";
elseif ( isDamage ) then
    return "DPS";
end
For example with Pitbull, create a new text, paste that in - done!
Even thou Pitbull has icons i think ill use this baby instead (But with a nice short H/T/D instead, or maybe even a colored *)

Offline
Reply With Quote
Old 12/18/09, 1:06 PM   #197
Faylar
Glass Joe
 
Draenei Shaman
 
Kul Tiras
Edit - please ignore, I figured it out

Last edited by Faylar : 12/18/09 at 10:42 PM.

Offline
Reply With Quote
Old 01/01/10, 11:23 PM   #198
onaforeignshore
Glass Joe
 
Blood Elf Priest
 
Nagrand (EU)
Originally Posted by Eyrika View Post
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.
I know it's 5 months later, but I just thought I'd share this optimised version with you and get your thoughts

if select(2, UnitClass("player")) == "PRIEST" then
    local pws, r, pom = "", "", ""
    if UnitAura(unit, "Power Word: Shield") or UnitAura(unit, "Weakened Soul") then
        pws = "|cffffffffPWS|r"
    end
    if UnitAura(unit, "Renew") then
        r = "|cff11a918Renew|r"
    end
    if UnitAura(unit, "Prayer of Mending") then
        pom = "|cffccbb66PoM|r"
    end
    return "%s%s%s", r, pom, pws
end
This uses my colour preferences, but you get the idea. Also, it eliminates a lot of unnecessary local variables and the use of the something and " " or "" problem. Also, as I'm using the frames for different players, I don't want to add extra testing if a class doesn't have the spells, hence the first line.

The UnitAura API allows testing of auras by index or by name, and since it returns nil or data, we don't need to assign it to any local variable.

Last edited by onaforeignshore : 01/01/10 at 11:58 PM.

Offline
Reply With Quote
Old 01/06/10, 10:34 PM   #199
Eyrika
Glass Joe
 
Eyrika's Avatar
 
Blood Elf Priest
 
Echo Isles
Originally Posted by onaforeignshore View Post
I know it's 5 months later, but I just thought I'd share this optimised version with you and get your thoughts

if select(2, UnitClass("player")) == "PRIEST" then
    local pws, r, pom = "", "", ""
    if UnitAura(unit, "Power Word: Shield") or UnitAura(unit, "Weakened Soul") then
        pws = "|cffffffffPWS|r"
    end
    if UnitAura(unit, "Renew") then
        r = "|cff11a918Renew|r"
    end
    if UnitAura(unit, "Prayer of Mending") then
        pom = "|cffccbb66PoM|r"
    end
    return "%s%s%s", r, pom, pws
end
This uses my colour preferences, but you get the idea. Also, it eliminates a lot of unnecessary local variables and the use of the something and " " or "" problem. Also, as I'm using the frames for different players, I don't want to add extra testing if a class doesn't have the spells, hence the first line.

The UnitAura API allows testing of auras by index or by name, and since it returns nil or data, we don't need to assign it to any local variable.
Hey, thanks so much for this! I tried out your code and it works perfectly. It's so much simpler, too, which i'm grateful for. That class check line is a great idea, too, since I play on different characters. I wouldn't have to make new profiles for each with my priest texts turned off.
Could I use that same line and combine, say, mage buffs into the same text?

Offline
Reply With Quote
Old 01/10/10, 4:47 PM   #200
Eyrika
Glass Joe
 
Eyrika's Avatar
 
Blood Elf Priest
 
Echo Isles
Originally Posted by Eyrika View Post
Hey, thanks so much for this! I tried out your code and it works perfectly. It's so much simpler, too, which i'm grateful for. That class check line is a great idea, too, since I play on different characters. I wouldn't have to make new profiles for each with my priest texts turned off.
Could I use that same line and combine, say, mage buffs into the same text?
Actually, upon further testing, the weakened soul part of this text doesn't seem to work. I thought it did at first, but now it doesn't. Maybe it's an addon I have conflicting or something. I found that in my original text, I needed to identify Weakened Soul as HARMFUL, but I'm not sure how to put it into this new text. I did UnitAura(unit,i, "Harmful", "Weakened Soul") but that didn't work.

Any ideas?

Offline
Reply With Quote
Reply

Go Back   Elitist Jerks » 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 634 12/03/10 7:21 PM
[DogTags] - Share yours! Fulnir User Interface and AddOns 164 03/30/08 2:30 AM