Thread Tools Display Modes
04/26/24, 01:27 PM   #1
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,033
Your EVENT_ADD_ON_LOADED is commented so I assume your addon never loads properly.

Use EVENT_ADD_ON_LOADED to Init once, it will fire for each addon so make sure you check for your addon''s name and after that unregister this event again!
In there register the EVENT_PLAYER_ACTIVATED event (this will fire again and again, if not unregistered, on EACH zone change with loading screen, teleport etc.).


Basically addons should always start like this, unless you need another usecase. Else your addons will init before other addons/dependencies like LibAddonMenu and LibChatMessage etc. are loaded and initialized!


Lua Code:
  1. EVENT_MANAGER:RegisterForEvent(GOLDMetrics.name, EVENT_ADD_ON_LOADED, function(eventId, addonName)
  2.    --any of the other addons currently loading?
  3.    if addonName ~=  GOLDMetrics.name then return end
  4.  
  5.    --my addon laoding
  6.    EVENT_MANAGER:UnregisterForEvent(GOLDMetrics.name, EVENT_ADD_ON_LOADED)
  7.  
  8.    --Init saved vars etc.
  9.    local settings = ZO_SavedVars:New*
  10.    --->Before EVENT_ADD_ON_LOADED the savedvars will be nil! So only assign them here, afterwards
  11.  
  12.    --Register other events
  13.    EVENT_MANAGER:RegisterForEvent(GOLDMetrics.name, EVENT_PLAYER_ACTIVATED, function(eventId, primary)
  14.     ----After chat has been initialized and player loaded into the ingame world
  15.    end)
  16. end)

Last edited by Baertram : 04/26/24 at 01:33 PM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » savedVariables returning nil


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