View Single Post
07-23-19, 06:38 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Blizzard_TimeManager.toc sets the time manager as LoadOnDemand, so it is not loaded initially.

UIParent attempts to load it twice, early if an alarm is enabled, then a second time at PLAYER_LOGIN:

Lua Code:
  1. function UIParent_OnEvent(self, event, ...)
  2.    
  3.     ...
  4.    
  5.     elseif ( event == "VARIABLES_LOADED" ) then
  6.    
  7.     ...
  8.    
  9.         if ( not TimeManagerFrame and GetCVar("timeMgrAlarmEnabled") == "1" ) then
  10.             -- We have to load the time manager here if the alarm is enabled because the alarm can go off
  11.             -- even if the clock is not shown. WorldFrame_OnUpdate handles alarm checking while the clock
  12.             -- is hidden.
  13.             TimeManager_LoadUI();
  14.         end
  15.    
  16.     ...
  17.    
  18.     elseif ( event == "PLAYER_LOGIN" ) then
  19.         TimeManager_LoadUI();

If it still somehow didn't load, TimeManager_LoadUI() is called when /stopwatch is used.

Since it should load at PLAYER_LOGIN, I suggest watching ADDON_LOADED like the Stopwatch does:

Lua Code:
  1. function StopwatchFrame_OnEvent(self, event, ...)
  2.     if ( event == "ADDON_LOADED" ) then
  3.         local name = ...;
  4.         if ( name == "Blizzard_TimeManager" ) then

Or just force it with TimeManager_LoadUI() a frame before your code.
  Reply With Quote