WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   A little script help for kgpanels (https://www.wowinterface.com/forums/showthread.php?t=25307)

MidgetMage55 07-09-09 02:26 PM

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.

Katae 07-09-09 03:16 PM

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 :)

MidgetMage55 07-09-09 04:57 PM

Thanks for the help. ill give it a test run and let you know =)

Seerah 07-09-09 09:06 PM

Take those two Hide() lines and move them into the OnLoad section of your scripts (where you register for the events).

Katae 07-09-09 10:14 PM

Quote:

Originally Posted by Seerah (Post 146625)
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.

Seerah 07-09-09 11:07 PM

Quote:

Originally Posted by Katae (Post 146629)
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


MidgetMage55 07-09-09 11:20 PM

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. =)

Seerah 07-10-09 09:26 AM

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


MidgetMage55 07-10-09 04:46 PM

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:

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.

Kapone 01-17-12 02:40 PM

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.

Kapone 01-20-12 10:54 PM

anyone =/?

Phanx 01-20-12 11:51 PM

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?

Kapone 01-21-12 09:06 AM

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.

Phanx 01-22-12 06:36 AM

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


Kapone 01-23-12 06:23 PM

Thanks allot =) it did the trick i had some issues tooday with that 11th persone.

Kapone 01-05-13 02:56 PM

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

Clamsoda 01-05-13 03:26 PM

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

Phanx 01-05-13 11:22 PM

Quote:

Originally Posted by Clamsoda (Post 271382)
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


Clamsoda 01-06-13 12:28 AM

Oops >.<. That's what I get for thinking too hard, then not trying the code. Thanks Phanx.

Kapone 01-06-13 07:15 AM

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")


All times are GMT -6. The time now is 05:11 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI