WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Blizzard_GuildUI Loaded OnDemand (https://www.wowinterface.com/forums/showthread.php?t=39775)

suicidalkatt 04-25-11 07:40 PM

Blizzard_GuildUI Loaded OnDemand
 
So I have an addon ( GuildRosterButtons ) that requires the loading on demand of the GuildUI in order to parent to the GuildFrame.

So calling the addon to load at the "PLAYER_LOGIN" event seems to be producing the issue of the guild level not being updated properly.

I've played around with the 'GuildFrame_UpdateLevel()' implementation into my code, but I'm kind of curious as to why the guild level isn't updated properly.

Is the player's guild info not available at the PLAYER_LOGIN event timing?

That seems a bit odd.

Ketho 04-25-11 10:40 PM

I've also had this problem before, with one of my addons
From my own experience:
  • GetGuildLevel already exists (defined somewhere in Blizzard's C code) on the PLAYER_LOGIN event, or any of the ADDON_LOADED events, but does not return the correct value yet (returns a zero)
  • Loading the Blizzard_GuildUI with LoadAddOn("Blizzard_GuildUI"), and/or ## OptionalDeps: Blizzard_GuildUI, and additionally calling GuildFrame_UpdateLevel(), doesn't have any effect on GetGuildLevel. It would still return a zero the first time a player logs in
  • This only occurs on the first game session whenever WoW has been started up; afterwards (after the first OnUpdate) it would always immediately return the correct value, for any character/guild.
TL;DR:
On the first game session, GetGuildLevel already exists, however it only returns the correct value after the first iteration of OnUpdate
Code:

LoadAddOn("Blizzard_GuildUI") -- no effect on GetGuildLevel

local f = CreateFrame("Frame")
f:RegisterEvent("ADDON_LOADED")
f:RegisterEvent("VARIABLES_LOADED")
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("PLAYER_ENTERING_WORLD")

f:SetScript("OnEvent", function(...)
        print(GetGuildLevel, GetGuildLevel(), ...)
        -- prints "function:", "0" (on first game session)
end)

Code:

local timeElapsed, iterations = 0, 0

local function OnUpdate(self, elapsed)
        timeElapsed = timeElapsed + elapsed
        iterations = iterations + 1

        if GetGuildLevel() > 0 then
                print(GetGuildLevel(), timeElapsed, iterations)
                -- prints "25", "0.017000000923872", "1"
                self:SetScript("OnUpdate", function() end)
        end
end

local f = CreateFrame("Frame")
f:SetScript("OnUpdate", OnUpdate)

I would just accept the "0" dummy value, and try to update it later afterwards

SDPhantom 04-25-11 10:48 PM

If you're basing your addon off a LoD addon, I would suggest using the LoadWith tag in the ToC. This will make your addon LoD and can only reference another LoD addon. There are more details in ToC Format. This tag is supported as of patch 1.9.

Ketho 04-25-11 10:55 PM

.. sorry, my bad on the LoadWith tag :(

SDPhantom 04-25-11 11:17 PM

It's just a suggestion for the OP. I discovered the LoadWith tag while making a couple addons that added additional features to the existing TrainerUI. Mainly, I added a statusbar that displayed your profession's level if you were at a profession trainer, and I added a "Train All" button that trains everything available in one click.

Aftermathhqt 04-26-11 04:27 AM

Code:

local AfterButtons = CreateFrame("Frame", nil, UIParent)
AfterButtons:RegisterEvent("ADDON_LOADED")
AfterButtons:SetScript("OnEvent", function(self, event, AddOn)
      if AddOn == "Blizzard_GuildBankUI" then
          --pewpew
      elseif AddOn == "Blizzard_GuildBankUI" then
          --pewpew
      end
end)

works very well aswell

suicidalkatt 04-26-11 04:52 PM

Thanks for the help and clarification!

I'll see what I can come up with.


All times are GMT -6. The time now is 02:13 AM.

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