Thread Tools Display Modes
12-21-10, 07:42 AM   #1
silentstone7
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2010
Posts: 14
Checking for a party or a raid

I'm working on my first addon, and I'm running into issues testing to see if the player is in a party or raid. Basically, I need to be able to call a function to test if a user is in a party, in a raid, or not in either.

I have a variable called partyShow, if it's set to true, the addon is only displayed in a raid and hidden in a party or alone. If it's false, it's always shown. I'm getting taint errors whenever this addon frame is hidden. Any ideas out there what might be wrong?

My current function is this:

function MBFlares_partyChecker() --hide/show in raid
if (MBFlaresDB.partyShow==true) then
if (GetNumRaidMembers() == 0) then -- NOT IN RAID
if (GetNumPartyMembers() == 0 ) then -- AND NOT IN A PARTY
MBFlares_mainFrame:Hide()
else -- IN A PARTY
MBFlares_mainFrame:Hide()
end
else -- IN A RAID
if IsRaidLeader() or IsRaidOfficer() then -- ABLE TO MARK
MBFlares_mainFrame:Show()
else --BUT NOT ABLE TO MARK
MBFlares_mainFrame:Hide()
end
end
else
MBFlares_mainFrame:Show()
end
end
  Reply With Quote
12-21-10, 02:39 PM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Checking for a boolean true is unnecessary in most cases:
Code:
if MBFlaresDB.partyShow == true then
if MBFlaresDB.partyShow then
You should use the [ CODE ] tag or [ highlight=Lua ][ /highlight ] to retain the indenting:
Lua Code:
  1. function MBFlares_partyChecker() -- hide/show in raid
  2.     if MBFlaresDB.partyShow then
  3.         if GetNumRaidMembers() == 0 then -- NOT IN RAID
  4.             if GetNumPartyMembers() == 0 then -- AND NOT IN A PARTY
  5.                 MBFlares_mainFrame:Hide()
  6.             else -- IN A PARTY 
  7.                 MBFlares_mainFrame:Hide()
  8.             end
  9.         else -- IN A RAID
  10.             if IsRaidLeader() or IsRaidOfficer() then -- ABLE TO MARK
  11.                 MBFlares_mainFrame:Show()
  12.             else -- BUT NOT ABLE TO MARK
  13.                 MBFlares_mainFrame:Hide()
  14.             end
  15.         end
  16.     else
  17.         MBFlares_mainFrame:Show()
  18.     end
  19. end
You could also just check against the Instance Type, since the player needs to be inside the raid/instance to mark the raid target mobs
(only "downside" is that this method doesn't show it outside the party/raid instance)

Lua Code:
  1. function MBFlares_partyChecker() -- hide/show in raid
  2.     if MBFlaresDB.partyShow then
  3.         local _, instanceType = IsInInstance()
  4.         if instanceType == "party" then -- IN A PARTY
  5.             MBFlares_mainFrame:Show()
  6.         elseif instanceType == "raid" and ( IsRaidLeader() or IsRaidOfficer() ) then -- IN A RAID AND ABLE TO MARK
  7.             MBFlares_mainFrame:Show()
  8.         else -- NOT ABLE TO MARK
  9.             MBFlares_mainFrame:Hide()
  10.         end
  11.     end
  12. end

Last edited by Ketho : 12-21-10 at 03:14 PM.
  Reply With Quote
12-21-10, 11:48 PM   #3
silentstone7
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2010
Posts: 14
Thank you! This is quite helpful! I'll make some changes and let you know how it goes.

Also, what exactly causes a "taint" error? I'm really not too sure.
  Reply With Quote
12-22-10, 05:12 AM   #4
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
I have never had experience with taint yet, but I can point you to some links:
Originally Posted by Nevcairiel
The plain and simple rule is, that everything created or modified from addon code will be tainted afterwards. Anything reading those tainted variables will also be tainted, and taint everything it modifies. (Thats the most common problem with taint spreading inside sensitive areas in the default UI.)
Originally Posted by Xinhuan
The main thing we need to know is there are 2 types of taint:

1. Execution Taint - Execution is tainted whenever it reads or executes data that is tainted.
2. Data Taint - Data is tainted when tainted execution writes data.
Afaik, you can :Hide() / :Show() your own addon's frame(s) without any problems
For the rest, I don't have any clue what in your addon could be tainting
Note: It's kinda hard to trace/debug the source of addon taint ...
Any addon could be wrongly "blamed" for tainting some protected function, unless you're running only that specific addon

Last edited by Ketho : 12-22-10 at 05:24 AM.
  Reply With Quote
12-22-10, 05:28 AM   #5
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
There's limitations to what you can do with secure frames when in combat. You can't change a buttons' attribute (basically what it does when clicked) nor can you move or hide/show it. You can alter the alpha but the button is still there, intercepting mouse clicks.

If you're not running them already, it would probably be helpful to install !BugGrabber and BugSack to get more descriptive errors.

You can check if you're able to alter some of this stuff by testing for InCombatLockdown().

http://wowprogramming.com/docs/api/InCombatLockdown
__________________
Oh, the simulated horror!
  Reply With Quote
12-22-10, 01:34 PM   #6
silentstone7
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2010
Posts: 14
Originally Posted by Ailae View Post
There's limitations to what you can do with secure frames when in combat. You can't change a buttons' attribute (basically what it does when clicked) nor can you move or hide/show it. You can alter the alpha but the button is still there, intercepting mouse clicks.

If you're not running them already, it would probably be helpful to install !BugGrabber and BugSack to get more descriptive errors.

You can check if you're able to alter some of this stuff by testing for InCombatLockdown().

http://wowprogramming.com/docs/api/InCombatLockdown
That might be the issue then, since I have it hiding and showing when the party changes and when the players target change, both of which can happen in combat.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Checking for a party or a raid


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off