Thread Tools Display Modes
04-25-11, 07:40 PM   #1
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
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.
  Reply With Quote
04-25-11, 10:40 PM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
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
  Reply With Quote
04-25-11, 10:48 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
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.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 04-25-11 at 10:51 PM.
  Reply With Quote
04-25-11, 10:55 PM   #4
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
.. sorry, my bad on the LoadWith tag
  Reply With Quote
04-25-11, 11:17 PM   #5
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
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.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
04-26-11, 04:27 AM   #6
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
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

Last edited by Aftermathhqt : 04-27-11 at 02:47 PM.
  Reply With Quote
04-26-11, 04:52 PM   #7
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Thanks for the help and clarification!

I'll see what I can come up with.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Blizzard_GuildUI Loaded OnDemand

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