This page explains the loading process and includes the event you need to check for.
https://wow.gamepedia.com/AddOn_loading_process
ADDON_LOADED will trigger for any addon that is loaded when you first log into the game.
The first argument is the name of the addon which is what you want to check for.. once you know the addon you are looking for is loaded you know the variables you want to use are available.
Lua Code:
local function onEvent(self,event,...)
if event == "ADDON_LOADED" then
local addonLoaded = ...
if addonLoaded == addonNameWaitingFor then
-- Work with stuff to do with the addon in question
end
elseif event == "VARIABLES_LOADED" then
-- current addon has its variables loaded
elseif event == "PLAYER_LOGIN" then
-- the player has logged into the game
elseif event == "PLAYER_ENTERING_WORLD" then
local login, reload = ...
if login then
-- Deal with once only initialisation of details that should never change between reloads
elseif reload then
-- Deal with reloaded information that may have changed since login
end
elseif event == "PLAYER_LOGOUT" then
-- Player is logging out .. deal with last minute changes here
end
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("VARIABLES_LOADED")
frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:RegisterEvent("PLAYER_LOGOUT")
frame:SetScript("OnEvent",onEvent)