View Single Post
05/29/16, 02:29 AM   #1
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,602
[outdated] d() before chat is initialized

Please consider the following change to the chat system, in order to allow debug messages to be shown from before EVENT_PLAYER_ACTIVATED.

Lua Code:
  1. function SharedChatSystem:Initialize(control, platformSettings)
  2.     self.cachedMessages = {}
  3. ...

Lua Code:
  1. function SharedChatSystem:AddMessage(text)
  2.     if IsChatSystemAvailableForCurrentPlatform() then
  3.         if(self.primaryContainer) then
  4.             self.primaryContainer:AddDebugMessage(text)
  5.         else
  6.             self.cachedMessages[#self.cachedMessages + 1] = text
  7.         end
  8.     end
  9. end

Lua Code:
  1. local function FlushMessageCache()
  2.     for i = 1, #self.cachedMessages do
  3.         self.primaryContainer:AddDebugMessage(self.cachedMessages[i])
  4.     end
  5.     self.cachedMessages = nil
  6. end
  7.  
  8. local function OnPlayerActivated()
  9.     playerActivated = true
  10.     TryLoadingSettings()
  11.  
  12.     if IsChatSystemAvailableForCurrentPlatform() then
  13.         if(not self.allowMultipleContainers) then
  14.             self:RedockContainersToPrimary()
  15.         end
  16.  
  17.         self:TryNotificationAndMailBursts()
  18.  
  19.         if(self.isAgentChatActive) then
  20.             self.agentChatBurstTimeline:PlayFromStart()
  21.         end
  22.     else
  23.         self.control:SetHidden(true)
  24.     end
  25.     FlushMessageCache()
  26. end