08-31-17, 03:54 PM | #1 |
Looking for Broken Code Help
I am having a timing issue show up in one of my addons and I'm hoping there is an elegant fix.
The addon has a frame to which an event handler is attached and the frame registers for the "ADDON_LOADED" AND "PLAYER_ENTERING_WORLD" events. The event handler checks for the appropriate events; along with the addon name in the case of the "ADDON_LOADED" event. Currently during the "ADDON_LOADED" event processing only a notification that the addon is loaded is produced. It is in the "PLAYER_ENTERING_WORLD" event processing that my issue is occurring. Prior to the recent 7.3 patch all was working good. That processing makes a call to the following module Code:
local function GetMyStats(getFullName) local pName = "me"; local pRank = -1; local pOcls = false; local rName ="Realm Name"; pName, rName = UnitFullName("player"); -- player name, player realm if (getFullName) then pName = pName.."-"..rName; end; if (IsInGuild()) then local gn, rn, ri, gr = GetGuildInfo("player"); -- guild name, rank name, rank index, guild realm if (gr == nil) then -- guild realm is nil if it is the same as the player's realm gr = rName; end; if (ri) then GuildControlSetRank(ri + 1); print("Guild Name: "..(gn or "nil")..", Guild Realm: "..(gr or "nil").."\nGuild Rank Index: "..(ri or "nil")..", Rank Name: "..(rn or "nil")); local gcl, gcs, ocl, ocs = GuildControlGetRankFlags(); for i, v in ipairs({GuildControlGetRankFlags()}) do local flag = _G["GUILDCONTROL_OPTION"..i]; print (ri, i, flag, v); end; if (ocl and ocs) then pOcls = true; end; pRank = ri; end; end; return pName, pRank, pOcls; end; Second, my primary issue is when the addon is first loaded and the "PLAYER_ENTERING_WORLD" fires for the first time, the function GetGuildInfo("player") is returning all nil values except for the rank index which is returned as zero. If while in game I then perform a /reload, the new call to GetGuildInfo("player") returns all values properly loaded. The output of the first time run is shown below. Code:
Guild Name: nil, Guild Realm: nil Guild Rank Index: 0, Rank Name: nil 0 1 Guildchat Listen false 0 2 Guildchat Speak false 0 3 Officerchat Listen false 0 4 Officerchat Speak false 0 5 Promote false 0 6 Demote false 0 7 Invite Member false 0 8 Remove Member false 0 9 Set MOTD false 0 10 Edit Public Note false 0 11 View Officer Note false 0 12 Edit Officer Note false 0 13 Modify Guild Info false 0 14 Create Guild Event false 0 15 Guild Bank Repair false 0 16 Withdraw Gold false 0 17 Create Guild Event false 0 18 Requires Authenticator false 0 19 Modify Bank Tabs false 0 20 Remove Guild Event false Originally, I made the call to the function shown during the "ADDON_LOADED" event processing but discovered that the player's realm name from UnitFullName() was not available until after the "PLAYER_ENTERING_WORLD" event fired. So, I moved it to the "PLAYER_ENTERING_WORLD" event processing and it has apparently been working until this recent release. Thank for any help or ideas. |
|
WoWInterface » Developer Discussions » General Authoring Discussion » Looking for Broken Code Help |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Switch to Hybrid Mode |
Threaded Mode |
|
|