View Single Post
01-29-20, 06:45 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
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:
  1. local function onEvent(self,event,...)
  2.  
  3.     if event == "ADDON_LOADED" then
  4.         local addonLoaded = ...
  5.         if addonLoaded == addonNameWaitingFor then
  6.           -- Work with stuff to do with the addon in question
  7.         end
  8.  
  9.     elseif event == "VARIABLES_LOADED" then
  10.         -- current addon has its variables loaded
  11.  
  12.     elseif event == "PLAYER_LOGIN" then
  13.         -- the player has logged into the game
  14.  
  15.     elseif event == "PLAYER_ENTERING_WORLD" then
  16.         local login, reload = ...
  17.         if login then
  18.            -- Deal with once only initialisation of details that should never change between reloads
  19.         elseif reload then
  20.           -- Deal with reloaded information that may have changed since login
  21.         end
  22.        
  23.     elseif event == "PLAYER_LOGOUT" then
  24.         -- Player is logging out .. deal with last minute changes here
  25.  
  26.     end
  27.    
  28. end
  29.  
  30. local frame = CreateFrame("Frame")
  31. frame:RegisterEvent("ADDON_LOADED")
  32. frame:RegisterEvent("VARIABLES_LOADED")
  33. frame:RegisterEvent("PLAYER_LOGIN")
  34. frame:RegisterEvent("PLAYER_ENTERING_WORLD")
  35. frame:RegisterEvent("PLAYER_LOGOUT")
  36. frame:SetScript("OnEvent",onEvent)
__________________

Last edited by Xrystal : 01-29-20 at 06:57 AM.
  Reply With Quote