1. #1
    Mechagnome MayronEU's Avatar
    Join Date
    Mar 2012
    Location
    England
    Posts
    574

    Big issue I want to fix for a script to switch profiles for Grid with KgPanels!

    Warning: This question is fairly technical so if you do not know a lot about lua then you may want to stop reading here!


    I have a big issue with my UI for a KgPanels script. When I press the Panel (which is a button for my UI) it will switch from DPS / Tank layout to Healer. When this happens it changes a few profiles around for me including Grid. However my problem is that some times when I switch Grid profiles, the frames are showing when they should not be or hide when they should be. To fix this I used the following Script in the OnUpdate Script area of my KgPanel:

    Code:
    if IsInGroup() then
    	GridLayoutFrame:Show()
    else
    	GridLayoutFrame:Hide()
    end
    and this one for the DPS frame:

    Code:
    if IsInRaid() then
    	GridLayoutFrame:Show()
    else
    	GridLayoutFrame:Hide()
    end
    This works completely find and makes the frames show instantly when switching grid profiles like it should be. HOWEVER when I change the Solo Layout from None to "BY Group 25" or anything else (from the "/grid" and Layout tab options) which should at least show my own Grid frame, the script forces it to show nothing because I am not actually in a group.

    I was wondering if there is anything I could do to work around this issue so for example a script to find out whether or not Solo is set to anything else besides "none" and if so the code above does not take effect but if Solo is on None then it does. That's just an idea.

    I have contacted the author of the Grid addon but not sure he can help me. He said to ask on a forum as it is more to do with KgPanels and mmo-champion is usually good for this stuff. Thank you so much for taking the time to read this!

  2. #2
    From a quick glance through the code, you should check the value of:
    Code:
    LibStub("AceAddon-3.0"):GetAddon("Grid"):GetModule("GridLayout").db.profile.layouts.solo
    UI & AddOns expert | Interface & Macros moderator - My work

  3. #3
    Mechagnome MayronEU's Avatar
    Join Date
    Mar 2012
    Location
    England
    Posts
    574
    I've been testing out "GetModule("GridLayout").db.profile.layouts.solo" for many days but was missing the starting part which is why I got so many errors. I will try this:

    Code:
    if not LibStub("AceAddon-3.0"):GetAddon("Grid"):GetModule("GridLayout").db.profile.layouts.solo then
    if IsInGroup() then
        GridLayoutFrame:Show()
    else
        GridLayoutFrame:Hide()
    end
    end
    EDIT: So far it seems to work but I need to test it some more. Thank you!

  4. #4
    I'm not sure what the value would be if you set the profile to "None". It might be string "none", or just boolean false / nil. Just /dump it in various scenarios to be sure.
    UI & AddOns expert | Interface & Macros moderator - My work

  5. #5
    Mechagnome MayronEU's Avatar
    Join Date
    Mar 2012
    Location
    England
    Posts
    574
    Quote Originally Posted by Treeston View Post
    I'm not sure what the value would be if you set the profile to "None". It might be string "none", or just boolean false / nil. Just /dump it in various scenarios to be sure.
    This is the exact same question I've been asking myself for a while. I thought it was a string of none after looking through the lua file but "if not" is working fine at the moment. Since the frames disappear randomly when I change profiles its hard to tell right now but if I find out that the code from my last post doesn't work then I will have to try checking if the value equals None or false/nil after.

  6. #6
    Just /dump the value?
    UI & AddOns expert | Interface & Macros moderator - My work

  7. #7
    Mechagnome MayronEU's Avatar
    Join Date
    Mar 2012
    Location
    England
    Posts
    574
    Oh sorry miss read as I have never used the /dump command before.

    I got this:

    Dump: value=LibStub("AceAddon-3.0"):GetAddon("Grid"):GetModule("GridLayout").db.profile.layouts.solo
    [1]="None"

    and then again when I set it to 25 Player in Solo Layout and got:

    Dump: value=LibStub("AceAddon-3.0"):GetAddon("Grid"):GetModule("GridLayout").db.profile.layouts.solo
    [1]="By Group 25"

    so yes it is a string.

  8. #8
    Well, you know what to do from here.

    PS:
    You might want to add an "else self:Show() end" at the bottom. Otherwise, swapping from None to something still won't show the frame.
    UI & AddOns expert | Interface & Macros moderator - My work

  9. #9
    Mechagnome MayronEU's Avatar
    Join Date
    Mar 2012
    Location
    England
    Posts
    574
    Yep thank you, got it all sorted and it works perfectly now. Tested it under many conditions:

    Code:
    if IsAddOnLoaded("Grid") then
        if LibStub("AceAddon-3.0"):GetAddon("Grid"):GetModule("GridLayout").db.profile.layouts.solo=="None" then
            if IsInGroup() then
                GridLayoutFrame:Show()
            else
                GridLayoutFrame:Hide()
            end
            else
                GridLayoutFrame:Show()
        end
    end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •