WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Script for OnClick only when in a group? (https://www.wowinterface.com/forums/showthread.php?t=45720)

Mayron 01-24-13 07:08 AM

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! :D 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


Phanx 01-24-13 09:48 PM

Quote:

Originally Posted by Mayron (Post 272320)
when I press a button to switch grid profiles, the grid frames disappear

What button are you pressing that is causing this issue?

Mayron 01-29-13 12:43 PM

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!

Phanx 01-29-13 05:24 PM

Do you have the same issue with the frame not appearing when you switch profile through the Grid options window?

Mayron 01-30-13 04:25 PM

Quote:

Originally Posted by Phanx (Post 272571)
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.


All times are GMT -6. The time now is 06:46 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI