Thread Tools Display Modes
07-09-09, 02:26 PM   #1
MidgetMage55
Grinch!
 
MidgetMage55's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,498
A little script help for kgpanels

Ok so heres the deal. For my raid healing ui i have 2 panels created for kgpanels. one for 10 and one for 25. The thing is i want the proper panels to show up based on the number of people i have in the raid.

I tired to work out the sample scripts on the page containing them over at wowace but im having the hardest time getting it to work. (translation i suck at anything pertaining to code)

In short:

In a 10 man raid id like panel 1 to show and panel 2 to hide. And the reverse to happen when in a 25 (1 to hide and 2 to show) and both hidden if im in a 5 man.

Any assistance would be appreciated.
__________________

I think Hong Kong Phooey was a ninja AND a pirate. That was just too much awesome. - Yhor
  Reply With Quote
07-09-09, 03:16 PM   #2
Katae
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 208
Code:
local party, mode = GetNumPartyMembers(), GetCurrentDungeonDifficulty()

-- hide both
PANEL1:Hide()
PANEL2:Hide()

-- 10 man normal mode
if party > 5 and mode == 1 then
    PANEL1:Show()

-- 25 man heroic mode
elseif party > 10 and mode >= 2 then
    PANEL2:Show()
end
Drycoded, but hope it helps

Last edited by Katae : 07-09-09 at 03:46 PM.
  Reply With Quote
07-09-09, 04:57 PM   #3
MidgetMage55
Grinch!
 
MidgetMage55's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,498
Thanks for the help. ill give it a test run and let you know =)
__________________

I think Hong Kong Phooey was a ninja AND a pirate. That was just too much awesome. - Yhor
  Reply With Quote
07-09-09, 09:06 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Take those two Hide() lines and move them into the OnLoad section of your scripts (where you register for the events).
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-09-09, 10:14 PM   #5
Katae
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 208
Originally Posted by Seerah View Post
Take those two Hide() lines and move them into the OnLoad section of your scripts (where you register for the events).
If that were done, it wouldn't hide PANEL1 when showing PANEL2, which is desired. Could be written other ways, but the Hide()/Show() happens so fast you shouldn't notice at all anyway.
  Reply With Quote
07-09-09, 11:07 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Katae View Post
If that were done, it wouldn't hide PANEL1 when showing PANEL2, which is desired. Could be written other ways, but the Hide()/Show() happens so fast you shouldn't notice at all anyway.
Ah, yes, you are right. I guess I only skimmed the code. But you want to hide them in OnLoad, or else they'll both be shown when you log in, until the event fires.

Put

PANEL1:Hide()
PANEL2:Hide()

in OnLoad and the OnEvent should be:

Code:
local party, mode = GetNumPartyMembers(), GetCurrentDungeonDifficulty()

-- 10 man normal mode
if party > 5 and mode == 1 then
    PANEL1:Show()
    PANEL2:Hide()

-- 25 man heroic mode
elseif party > 10 and mode >= 2 then
    PANEL2:Show()
    PANEL1:Hide()
end
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-09-09, 11:20 PM   #7
MidgetMage55
Grinch!
 
MidgetMage55's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,498
Just to experiment i did it both ways and they hide in both versions. What i did change however is in each panel i only had it hide itself

simply
self:Hide() and that worked just fine. having a panel name or number was causing issues. the numbers changed each time i did a /reloadui so that wasnt going to work. and the names kept throwing errors.

What i ended up with after much fussing and trying to learn what the hell was going on ( as well as learing a little bit anout the local tyhingy at the beginning) i have this:

Code:
local inRaid = UnitInRaid("player")
local inParty = UnitInParty("player")

if inRaid and GetNumRaidMembers() < 11 then
      self:Show()
   -- in 10 man raid
elseif inRaid and GetNumRaidMembers() > 10 then
      self:Hide()
   -- in 20 man raid
elseif inParty and GetNumPartyMembers() > 1 then
      self:Hide()
   -- in a 5 man party
end
and reversed the self:Hide() parameters for the first 2 bits and left them both hidden for party in the 25 man panel. Had the Mrs. join a raid with me and the 10 man panel showed up perfectly and disappeared when we left the raid. Havent tested it with 25 man yet.

For the OnLoad bit i just slapped in there what was on the wowace page with examples. No idea if its necessary ot not but here it is (be gentle im still learning hehe):
Code:
 self:RegisterEvent("PLAYER_ENTERING_WORLD")
 self:RegisterEvent("PARTY_MEMBERS_CHANGED")
 self:RegisterEvent("RAID_ROSTER_UPDATE")

-- Hide panel
self:Hide()
This is in the OnLoad for both panels and so far no errors. Though if anything i have is unnecessary or likely to be a potential source of problems im always up for learning more.

As always thanks for the help. =)
__________________

I think Hong Kong Phooey was a ninja AND a pirate. That was just too much awesome. - Yhor
  Reply With Quote
07-10-09, 09:26 AM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You can't do this in each panel though. You can only register an event once. Unless that was just a restriction of eePanels (or it has changed since kgPanels was first released...) In the kgPanels in-game FAQ is a way to get a reference to a panel so you can call multiple panels from one script. I think it's
Code:
kgPanels:Fetch("the name you gave the panel when you made it")
So, pick one panel (probably best is the one with a higher panel number) and put the code in there. It'll make it easier to change later anyway, to have it all in one spot...

OnLoad:
Code:
 self:RegisterEvent("PLAYER_ENTERING_WORLD")
 self:RegisterEvent("PARTY_MEMBERS_CHANGED")
 self:RegisterEvent("RAID_ROSTER_UPDATE")

local tenman = kgPanels:Fetch("thatpanel'sname")
local twentyfive = kgPanels:Fetch("thatone'sname")

-- Hide panels
tenman:Hide()
twentyfive:Hide()
OnEvent:
Code:
local inRaid = UnitInRaid("player")
local inParty = UnitInParty("player")
local tenman = kgPanels:Fetch("thatpanel'sname")
local twentyfive = kgPanels:Fetch("thatone'sname")

if inRaid and GetNumRaidMembers() < 11 then
      tenman:Show()
      twentyfive:Hide()
   -- in 10 man raid
elseif inRaid and GetNumRaidMembers() > 10 then
      tenman:Hide()
      twentyfive:Show()
   -- in 20 man raid
elseif inParty and GetNumPartyMembers() > 1 then
      tenman:Hide()
      twentyfive:Hide()
   -- in a 5 man party
end
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-10-09, 04:46 PM   #9
MidgetMage55
Grinch!
 
MidgetMage55's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,498
Ahh so thats how you use the fetch bit. ill have to do that then and see how it goes.

As for registering the event in both panels i recall it being mentioned on the sample scripts page though i may have misread it. I just went to look abnd the page is throwing an error at the moment so ill edit later once i can access the page.

As far as putting the scripts in the panel with the higher number when ever i use the script to find a frame and get the numbers then do a /reloadui the numbers kept changing. Example being the 10 man panel listed as panel 1 initially then after reload it was panel 3. To be fair i havent updated kgpanels in forever since ive never had an issue so ill try that first.

Thanks again for the assist. Learning little by little hehe.

EDIT: Finally got the page of the sample scripts to load, this is a direct quote:

Adjusting Panels based on Raid or 5 Main party

In each Panel set the OnLoad script

self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("RAID_ROSTER_UPDATE")

Then in each Panel OnEvent script:

local pmems = GetNumPartyMembers()
local rmems = GetNumRaidMembers()
if (pmems < 1 and rmems < 1) or (pmems > 0 and pmems < 6 and rmems < 6) then
self:Hide()
else
self:Show()
end
Obviously there are slight differences in the actual script but the general idea is the same. you'll also note it does mention putting it in each panel. though i agree if i can do it in one panel (perhaps one that isnt going to be hidden at all if possible) makes it easier to fix later.
__________________

I think Hong Kong Phooey was a ninja AND a pirate. That was just too much awesome. - Yhor

Last edited by MidgetMage55 : 07-10-09 at 04:49 PM. Reason: update
  Reply With Quote
01-17-12, 02:40 PM   #10
Kapone
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 16
been trying out these codes for a while and i would like too bring up this old thread.

I need help with hiding 2 textures (background and overlayer) when i go in too 10 man aswell as hiding 2 textures when im 10 man (2 different textures for 10 and 25 man).

Party dosen't matter
So when im in raid 2>10 i want Raid 10 and Raid 10 ol (panel name) only being seen and Panel name: Raid 25 with Raid 25 ol hiding. and then Raid 25 with Raid 25 ol shown when its 11 ppl in the raid.

I have anchor'd raid 25 so it shows when some one enter the 3d group in a raid. so all i have too do is hide 10 man raid texture when the 25 one pops up. ive been trying to go on lazy stile and tryed too cower the other texture with panel lvls but it does not work as i want becouse of the overlayer.

Edit:

So after a few hours i think i got it right. but i would like someone too take an eye pop if i got it right..

For OnLoad:
Code:
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("RAID_ROSTER_UPDATE")
For Raid frame 10memmbers and over layer:
Code:
local pmems = GetNumPartyMembers()
local rmems = GetNumRaidMembers()
if (pmems > 0 and rmems > 1 and rmems < 11) then
self:Show()
else
self:Hide()
end
For raid frame 25memmbers and over layer:
Code:
local pmems = GetNumPartyMembers()
local rmems = GetNumRaidMembers()
if (pmems > 0 and rmems > 10 and rmems < 26) then
self:Show()
else
self:Hide()
end
Note that i want too show raid frame even when im solo in raid. and get the 25 man texture up when its 11 members in that raid.


Many thanks and spank's
Kapone over and out.

Last edited by Kapone : 01-17-12 at 05:41 PM.
  Reply With Quote
01-20-12, 10:54 PM   #11
Kapone
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 16
anyone =/?
  Reply With Quote
01-20-12, 11:51 PM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Your code looks fine. Your post was very hard to follow between the long run-on sentences, the shortage of punctuation, and the surplus of spelling errors. If you really need to use such long sentences, please use commas to break them up into more readable pieces. If there was a question in there that needed an answer, I missed it. Is your code not working the way you want it to? If not, what behavior do you need to change, and what trouble are you having trying to change it?
  Reply With Quote
01-21-12, 09:06 AM   #13
Kapone
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 16
Sorry for bad spelling.
My Question is if that code will Load the 10 man raid texture when at least 1 person is in raid.
A switch too 25 man raid texture when the raid hits 11 member's and higher also.

I'd rather ask someone that knows before i upload a new version of my ui. and looking for raids when i barley have any time too play aint a option.

Thanks for a answer Phanx and i hope this one was more read-able.
  Reply With Quote
01-22-12, 06:36 AM   #14
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
No; the way you've written your code, the 10-man texture will show when:
  • there is at least one party member, (n>0)
  • there is more than one raid member, (n>1) and
  • there are fewer than eleven raid members. (n<11)
I don't think the first two are what you actually wanted.

To get something that shows when there are 1-10 raid members, and hides otherwise, it doesn't matter how many people are in your party, so you don't need to check that:
Code:
local raid = GetNumRaidMembers()
if raid >= 1 and raid <= 10 then
     self:Show()
else
     self:Hide()
end
The same goes for 11-25 raid members; you don't need to check party members:
Code:
local raid = GetNumRaidMembers()
if raid >= 11 and raid <= 25 then
     self:Show()
else
     self:Hide()
end
  Reply With Quote
01-23-12, 06:23 PM   #15
Kapone
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 16
Thanks allot =) it did the trick i had some issues tooday with that 11th persone.
  Reply With Quote
01-05-13, 02:56 PM   #16
Kapone
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 16
thanks too blizzards new update allot of my code is broken.. this is what i have at the moment
On load: All panels get it (10 man + 10man ol and 25man etc)

Code:
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("GROUP_ROSTER_UPDATE")
On event: For showing 10 man panel.
Code:
local raid = GetNumRaidMembers()
if raid >= 1 and raid <= 10 then
     self:Show()
else
     self:Hide()
end
On event: For hiding 10 man panel and showing 25 man
Code:
local raid = GetNumRaidMembers()
if raid >= 11 and raid <= 26 then
     self:Show()
else
     self:Hide()
end
If anyone could link me what got changed in mop or if someone wanna feel kind today and change what i should change so it works for me ^^
Anyways and eighter way thanks already
  Reply With Quote
01-05-13, 03:26 PM   #17
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
GetNumRaidMembers has been replaced with GetNumGroupMembers and IsInRaid.

Use the IsInRaid() boolean to make sure you are in a raid, and use GetNumGroupMembers to replace the functionality of GetNumRaidMembers.

Try:

Lua Code:
  1. local raid = GetNumGroupMembers()
  2. if IsInRaid() and raid >= 1 and raid <= 10 then
  3.      self:Show()
  4. else
  5.      self:Hide()
  6. end

Expand the concepts to where ever else you need.

Edit: I suppose you could remove the "raid" variable, and change the IF statement to:

Lua Code:
  1. if IsInRaid() and GetNumGroupMembers() >=1 and <= 10 then

Last edited by Clamsoda : 01-05-13 at 03:34 PM.
  Reply With Quote
01-05-13, 11:22 PM   #18
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Clamsoda View Post
Lua Code:
  1. if IsInRaid() and GetNumGroupMembers() >=1 and <= 10 then
That isn't valid Lua code... you'd need to do:
Code:
if IsInRaid() and GetNumGroupMembers() >=1 and GetNumGroupMembers() <= 10 then
But you're better off just using what you originally posted, so you're not duplicating function calls:
Code:
local n = GetNumGroupMembers()
if IsInRaid() and n > 0 and n < 11 then
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-06-13, 12:28 AM   #19
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
Oops >.<. That's what I get for thinking too hard, then not trying the code. Thanks Phanx.
  Reply With Quote
01-06-13, 07:15 AM   #20
Kapone
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 16
Okey. but ive tried out
Code:
local n = GetNumGroupMembers()
if IsInRaid() and n > 1 and n < 10 then
     self:hide()
else
     self:show()
end
and
Code:
local n = GetNumGroupMembers()
if IsInRaid() and n > 0 and n < 11 then
     self:Show()
else
     self:Hide()
took a shot with
Code:
if IsInRaid() and GetNumGroupMembers() >=1 and GetNumGroupMembers() <= 10 then
     self:Show()
else
     self:Hide()
also
Code:
local raid = GetNumGroupMembers()
if IsInRaid() and raid >= 1 and raid <= 10 then
     self:Show()
else
     self:Hide()
end
And still my 10 man and 25 man panel is showing at the same time =(
Im not sure if the onload is right or if i just put things in wrong place's =/

Onload:
Code:
self:RegisterEvent("GROUP_ROSTER_UPDATE")

Last edited by Kapone : 01-06-13 at 07:48 AM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » A little script help for kgpanels

Thread Tools
Display Modes

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