Thread Tools Display Modes
08-02-20, 01:24 AM   #1
Lev
A Kobold Labourer
Join Date: Aug 2020
Posts: 1
I need an event that occurs later than PLAYER_ENTERING_WORLD

Not sure how many people use Communities at all, but there's an annoying bug where community chat can be hidden when you log in. To fix this in-game, you can open your Chat Channels list and click the box next to the community chat channel to hide it, and then click it again to reshow it.

With this knowledge, I found ChatFrame_RemoveChannel and ChatFrame_AddChannel serve the same purpose as clicking that box in the chat channel UI.
Code:
ChatFrame_RemoveChannel(DEFAULT_CHAT_FRAME, "Community:XXXXXXX:1")
ChatFrame_AddChannel(DEFAULT_CHAT_FRAME, "Community:XXXXXXX:1") 
(the XXXXXXX is a string of numbers that's basically the community's ID, 
not sure if I should post that here)
I can run these in-game via /script and it fixes the chat bug. I've been having an issue automating it though, because the chat doesn't seem to bug out until after loading into WoW. I can run RemoveChannel on the PLAYER_LOGIN event perfectly fine, but AddChannel seems to need a delay. PLAYER_ENTERING_WORLD is too soon and it doesn't work. The *only* solution that has worked is using a 20 second timer after PLAYER_ENTERING_WORLD, but that probably isn't a consistent solution if I share this addon with my community. Does anyone have any ideas?

Code:
local frame=CreateFrame("Frame");
frame:RegisterEvent("PLAYER_LOGIN");
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:SetScript("OnEvent",function(self,event,...)
    if (event=="PLAYER_LOGIN") then
    ChatFrame_RemoveChannel(DEFAULT_CHAT_FRAME, "Community:XXXXXXX:1")
    elseif (event=="PLAYER_ENTERING_WORLD") then
    C_Timer.After(20, function() ChatFrame_AddChannel(DEFAULT_CHAT_FRAME, "Community:XXXXXXX:1") end)
    frame:UnregisterAllEvents() 
    end
end)
  Reply With Quote
08-02-20, 01:48 AM   #2
glupikreten
A Theradrim Guardian
Join Date: Apr 2009
Posts: 60
I'm new to lua and wow lua so im trying to get a grasp at how things work and what is life cycle of an addon(s)...

I struggled with this also and havent found any solution besides delaying my functions also... For me workd 10 sec... i guess that depends on speed of computer.. how fast can load shit.. dunno in what time counter starts.. is it after loading all addons.. or that one particulary.. or after loading all addons and some blizzard event... i just noticed that sometimes my function fires after 5-6 seconds image appears on mz screen.. sometimes its 8-9...

I'd like better solution aswell

Still im puzzled how to reposition, set height/width of combat frame... all others work as espected except that one... well i guess in time

Last edited by glupikreten : 08-02-20 at 04:31 AM.
  Reply With Quote
08-02-20, 10:02 AM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Possibly UPDATE_CHAT_WINDOWS
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-02-20, 01:48 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
The addon Blizzard_Communities is LoadOnDemand. Out of all actions in the UI that load it, the one that usually gets it first is when your chat channel list updates in FrameXML\ChannelList.lua:101

Lua Code:
  1. function ChannelListMixin:Update()
  2.  
  3. ...
  4.  
  5.     -- Then add community streams
  6.     local clubs = C_Club.GetSubscribedClubs();
  7.  
  8.     Communities_LoadUI(); -- here
  9.     CommunitiesFrame.CommunitiesList:PredictFavorites(clubs);
  10.     CommunitiesUtil.SortClubs(clubs);
  11.  
  12. ...
  13.  
  14. end

The event you want is ADDON_LOADED after force-loading Communities at login:

Lua Code:
  1. local frame=CreateFrame("frame")
  2. frame:RegisterEvent("ADDON_LOADED")
  3. frame:RegisterEvent("PLAYER_LOGIN")
  4. frame:SetScript("OnEvent",function(self,event,arg1)
  5.     if event=="ADDON_LOADED" and arg1=="Blizzard_Communities" then
  6.         ChatFrame_AddChannel(DEFAULT_CHAT_FRAME,"Community:XXXXXXX:1")
  7.     elseif event=="PLAYER_LOGIN" then
  8.         Communities_LoadUI()
  9.     end
  10. end)

You don't need to call ChatFrame_RemoveChannel. It's possible that the act of toggling the community loads Communities and for some reason Blizzard doesn't load Communities appropriately at login.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » I need an event that occurs later than PLAYER_ENTERING_WORLD

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