View Single Post
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