WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   [HELP] Display Guild Frame? (https://www.wowinterface.com/forums/showthread.php?t=37368)

Zax 12-05-10 09:47 AM

[HELP] Display Guild Frame?
 
Hello,

Does anyone know how to display the main guild frame (the one where guildmates are listed) from an AddOn?

I tried the basic "GuildFrame:Show();" but wow returns this LUA error: "attempt to index global 'GuildFrame' (a nil value)"

Thanks in advance.

sacrife 12-05-10 09:57 AM

the :Show command only show's it if it is initially hidden or hidden on purpose.

You need to find a toggle version of it.
ToggleGuildFrame();

Dridzt 12-05-10 10:30 AM

What sacrife said.

Keep in mind that the guild is nowadays a load on demand blizzard addon.
"Blizzard_GuildUI".

Depending how soon you try to show it it might not be loaded.
For unguilded players I'm not sure it loads at all.

Do not try to force load it as that tends to break other Blizzard addons (Calendar for example).

Your best bet is monitoring ADDON_LOADED for "Blizzard_GuildUI" as first argument,
then you know it's available.

Hope it helps.

Zax 12-05-10 02:22 PM

Thanks :)

Keeping in mind what you said, I tried this:
Code:

if (IsInGuild()) then
        if (not IsAddOnLoaded("Blizzard_GuildUI")) then
                local loaded, reason = LoadAddOn("Blizzard_GuildUI");
                if not loaded then
                          echo("Blizzard_GuildUI not loaded: "..reason);
                  else
                          echo("**************** TEST *********************");
                          ToggleGuildFrame();
                  end;
          else
                  ToggleGuildFrame();
          end
end

But it doesn't work (my personal echo() function just displays a text in the chat box): the TEST message in well displayed but the guild frame is not shown. I suppose it is because this script is called on VARIABLES_LOADED event.

I was just trying to display guild frame when entering WoW in order to quickly see the connected guildmates.

Dridzt 12-05-10 03:06 PM

Quote:

Originally Posted by Zax (Post 221648)
Thanks :)

Keeping in mind what you said, I tried this:

But it doesn't work (my personal echo() function just displays a text in the chat box): the TEST message in well displayed but the guild frame is not shown. I suppose it is because this script is called on VARIABLES_LOADED event.

I was just trying to display guild frame when entering WoW in order to quickly see the connected guildmates.

Yes your guess is correct, VARIABLES_LOADED is too early.
Also LoadAddOn() is not good practice, it can break other LoD Blizzard addons, most notably the Calendar.
This might be better:
Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:SetScript("OnEvent",
  3. function(self,event,...)
  4.     if self[event] then
  5.         self[event](...)
  6.     end
  7. end)
  8. f:RegisterEvent("ADDON_LOADED")
  9. function f.ADDON_LOADED(...)
  10.     local addon = ...
  11.     if addon == "Blizzard_GuildUI" then
  12.         ToggleGuildFrame()
  13.     end
  14. end

henrik_s 12-05-10 03:42 PM

It seems the frame is not created until you open it (manually). After that GuildFrame:Show() should work.

p3lim 12-05-10 08:11 PM

ToggleGuildFrame() loads Blizzard_GuildUI upon use, so no need to wait for it.

https://github.com/tekkub/wow-ui-sou...arent.lua#L443

Dridzt 12-05-10 08:31 PM

Yes but the only 2 places the default client calls that function is when you click the microbutton,
or use the keybind.

In both cases the game is fully loaded.

Calling it from addon code at say VARIABLES_LOADED will cause the same problem I pointed out above as if you did LoadAddOn() or ## RequiredDependencies on an addon.

It's not the best idea.

You either need for it to load "normally" or delay calling that function sufficiently.

p3lim 12-05-10 08:34 PM

I belive the GuildUI is loaded on demand, but I could be wrong.

Dridzt 12-05-10 08:39 PM

You're absolutely right.
I mentioned that on post #3.

The problem is that Blizzard "assumes" the several Blizzard_ LoD addons will load in a specific order.

This is an implicit assumption though they are not ReqDep on each other.

This (which is essentially a lack of forethought on their part, not addon author's part)
causes obscure side-effects when you force-load Blizz LoD addons (like GuildUI) too early.

Zax 12-06-10 10:20 AM

I tried your script Dridzt (thanks to post it).
The guild frame was not shown but when I press my key to show it, WoW played the standard little sound and the guild frame didn't appear. Si I believe your script calls the frame without showing it and when I pressed my "guild" shortcut, WoW closed the guild pane.
I reloaded the UI and WoW crashed (it never crashes on my computer).

So, considering the goal - just show the guild pane on connect - I think I will abandon this non-essential feature. I didn't think it would be so difficult (it worked very easily on pre 4.x Wow version.

Anyhow, thanks all for your help.


All times are GMT -6. The time now is 09:02 PM.

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