Thread Tools Display Modes
01-24-13, 07:08 AM   #1
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Script for OnClick only when in a group?

Hi I've got an annoying issue where when I press a button to switch grid profiles, the grid frames disappear but I noticed that if I use:

"/run GridFrameLayout:Show()" then it fixes the problem so what I want to do is build this into my button I've made.

However I only want it to apply if I am in a group as I do not want it to show my frame when I am on my own. What function would I need and how would it look like?

If anyone can help me with this that would be fantastic! Thank you!

--------------------------------------

EDIT: I fixed it!

I'm using the following code which seems to work perfectly:

Code:
if IsInGroup() then
    GridLayoutFrame:Show()
else
    GridLayoutFrame:Hide()
end

Last edited by Mayron : 01-24-13 at 08:36 AM.
  Reply With Quote
01-24-13, 09:48 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Mayron View Post
when I press a button to switch grid profiles, the grid frames disappear
What button are you pressing that is causing this issue?
__________________
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-29-13, 12:43 PM   #3
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Sorry for the delayed reply. I am pressing a button I made using KgPanels:

OnClick:
Code:
if InCombatLockdown() then return end

if pressed then
	if IsAddOnLoaded("Grid") then
		Grid.db:SetProfile("MayronUIH2")
	end
end
Also that last script I posted works very well except I can no longer set the Solo Layout to anything besides none as it does not show so I can't set up my Grid frames while out of a group or raid. I want to add something to fix this so I've looked into the GridLayout.lua but I couldn't find anything that would help me.

All I want to do is to be able to click my button and the Grid profiles change but show up instantly because without that code, if I am in an instance then there is either a very large delay or I need to reload the UI. I cannot use this button while out of combat which is good otherwise I would expect some sort of error. Also I have noticed that sometimes if I press the button then the profiles change and the Grid frames are showing even if I am on my own and the solo layout is set to none so they should not be there but they are. So this code I came up with corrects these two issues but now I cannot use the solo layout to configure the frames.

I was thinking I could add something that checks the grid solo layout and shows if the layout is set to something besides none else it does what the code already says. I am very bad with lua so not sure if that is possible or not. Thank you for reading!
  Reply With Quote
01-29-13, 05:24 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Do you have the same issue with the frame not appearing when you switch profile through the Grid options window?
__________________
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-30-13, 04:25 PM   #5
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by Phanx View Post
Do you have the same issue with the frame not appearing when you switch profile through the Grid options window?
The issue still persists when I have all other Grid plugins disabled and I change the profiles manually with the "/grid" profiles tab menu. I've even tested this on my own solo while out of combat in a non busy location and when I switch to my Healing profile, my frame shows up when solo is set to none for no reason. And during instances frames can disappear and reappear on their own with delays when changing profiles out of combat.

Fortunately though the lua errors have stopped since I disabled that one Grid plugin so its not as bad but still can be annoying as I have to reload the UI to fix the issue. My code worked to fix this but its just a pain to not be able to change solo to 25 player for example so that I can config the frames out of instances.

Last edited by Mayron : 02-01-13 at 05:31 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Script for OnClick only when in a group?

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