WoWInterface (
-   AddOn Help/Support (
-   -   kgpanels script to display pvp icon? (

kerouan 11-15-12 09:29 AM

kgpanels script to display pvp icon?
Hi. What I'm looking to do is the following:
  • Display a panel when i select a target and the target is pvp (or ffa) flagged.
  • If i select a target that isn't flagged, it will not display anything.
  • Display a different background artwork if the unit is Horde, Alliance, or FFA.

The FFA options are much lower importance than the horde/alliance artwork.

I've tried messing with some of the code from this thread ( but was never able to get anything to actually display.

Ekaterina 11-15-12 11:24 PM

Try this - which is modified code from the forum post you linked.

In your onload script:
Lua Code:
  1. self:RegisterEvent("PLAYER_ENTERING_WORLD")
  2. self:RegisterEvent("PLAYER_TARGET_CHANGED")
  4. self:Hide()

In your onevent script:
Lua Code:
  1. local FFA_PVP_TEXTURE = "Interface\\TargetingFrame\\UI-PVP-FFA" -- The paths to the textures to be used when the player is flagged for FFA/regular PvP.
  2. local REG_PVP_TEXTURE = "Interface\\TargetingFrame\\UI-PVP-%f"  -- %f in both paths will be replaced with either Horde or Alliance, depending on the player's faction.
  4.  self:Hide()
  5. local faction = UnitFactionGroup("target")    
  7. if UnitIsPVPFreeForAll("target") then        
  9.     self:Show()
  10. elseif UnitIsPVP("target") then        
  11."%%f", faction))        
  12.     self:Show
  13. end


Phanx 11-16-12 03:03 AM

You could make that more efficient by (1) using either simple string concatenation, or string.format with the standard substitution token %s, instead of using the more expensive string.gsub with the custom substitution token %f (which is actually a real Lua pattern token indicating a floating-point numeric value), and (2) only hiding the frame if it's actually supposed to be hidden, instead of unconditionally hiding it and then conditionally showing it again immediately afterward.

Also, it's a good practice to only declare variables (I'm looking at your "faction" variable) in the most limited scope where they are useful, and in this case since the value from UnitFactionGroup will only be used once, there's not even any need to store it in a variable. Same goes for the texture paths; there's no reason to assign them both to variables when only one might be used. I'm guessing this script was originally adapted from an arena macro; the authors of those are notorious for misunderstanding the purpose of variables, and assigning everything to a variable even when it's only used once (or not at all) and actually takes up more space in their macro.




if UnitIsPVPFreeForAll("target") then"Interface\\TargetingFrame\\UI-PVP-FFA")
elseif UnitIsPVP("target") then"Interface\\TargetingFrame\\UI-PVP-" .. UnitFactionGroup("target"))

kerouan 11-16-12 06:49 AM

This worked great! Thank you!

All times are GMT -6. The time now is 04:19 AM.

vBulletin © 2018, Jelsoft Enterprises Ltd
© 2004 - 2017 MMOUI