WoW:AddOn loading process: Difference between revisions

m
no edit summary
mNo edit summary
Line 1: Line 1:
{{uiaddon}}
{{uiaddon}}


This document describes the WoW [[UI Customization]] aspect of load order for loading addons. It covers when the WoW client first starts up, when AddOns load for the first time, and when user or WoW reloads the [[UI]]. The availablity of the Lua environment at various points in the process is also detailed.
This document describes the WoW [[UI Customization]] aspect of load order for loading [[AddOn]]s. It covers when the WoW client first starts up, when AddOns load for the first time, and when user or WoW reloads the [[UI]]. The availability of the Lua environment at various points in the process is also detailed. The term '[[WoW Client]]' means: the WoW game program that's launched to play WoW.  


== General steps ==  
== General steps ==  


# Intial Scan - When the WoW client first starts, a list of files and addon dependencies is built.
# Initial Scan - When the WoW client first starts, a list of files and AddOn dependencies is built.
# AddOn Load - Addon code is executed after the player selects a character and chooses to enter the world.
# AddOn Load - AddOn code is executed after the player selects a character and chooses to enter the world.
# After all addon code has been loaded, the saved variables are executed. ADDON_LOADED fires after each addon's SVs have been loaded.
# After all AddOn code has been loaded, the saved variables are executed. ADDON_LOADED fires after each AddOn's SVs have been loaded.


=== Initial Scan ===
=== Initial Scan ===


First, the WoW client scans through all of the folders in the '''Interface\AddOns''' directory, looking for sub-folders containing a valid [[TOC file]] with a '.toc' extension, and in turn then loads each AddOn's TOC file into memory. TOC files that were not found during this step cannot be loaded by the game later and only happens on client start-up. This makes it impossible to install additional addons, or load updated TOC files, without restarting the client. For a AddOn to be considered valid, it must have a single word folder directly in the '''Interface\AddOns''' folder, and must have a matching named '.toc' file, such as a 'MyAddon' folder with a 'MyAddOn.toc' underneath it.  That is all that is requred.
First, the WoW client scans through all of the folders in the '''Interface\AddOns''' directory, looking for sub-folders containing a valid [[TOC file]] with a '.toc' extension, and in turn then loads each AddOn's TOC file into memory. TOC files that were not found during this step cannot be loaded by the game later and only happens on client start-up. This makes it impossible to install additional AddOns, or load updated TOC files, without restarting the client. For a AddOn to be considered valid, it must have a single word folder directly in the '''Interface\AddOns''' folder, and must have a matching named '.toc' file, such as a 'MyAddon' folder with a 'MyAddOn.toc' underneath it.  That is all that is required.


=== AddOn Load ===
=== AddOn Load ===


AddOn loading occurs when the player logs in. The dependency information in the .toc files is used, in part, to compute the order in which the addons files will be loaded, as well as the natural order in which the AddOns were discovered during the scan process. For AddOns with dependancies, an individual addon may '''not''' assume that all of the other addons that it depends on will be loaded first, without taking specific steps to ensure its dependancies are already loaded and available. When WoW loads a particular AddOn it uses the information in its [[TOC file]] discovered during initial scan and loads each file in order that it is found inside the TOC.
AddOn loading occurs when the player logs in. The dependency information in the .toc files is used, in part, to compute the order in which the AddOns files will be loaded, as well as the natural order in which the AddOns were discovered during the scan process. For AddOns with dependencies, an individual AddOn may '''not''' assume that all of the other AddOns that it depends on will be loaded first, without taking specific steps to ensure its dependencies are already loaded and available. When WoW loads a particular AddOn it uses the information in its [[TOC file]] discovered during initial scan and loads each file in order that it is found inside the TOC.


== Inside the TOC file ==
== Inside the TOC file ==


Files within an addon are loaded in the order they're listed in the addon's .toc file. Files included through XML <Include file="src.xml" /> or <Script file="src.lua" /> are loaded at the time the tag is encountered while parsing. XML OnLoad script handlers execute when all of a widget's children have been created.
Files within an AddOn are loaded in the order they're listed in the AddOn's [[TOC file]], named [addonname].toc. Files included through XML <Include file="src.xml" /> or <Script file="src.lua" /> are loaded at the time the tag is encountered while parsing. XML OnLoad script handlers execute when all of a widget's children have been created.


When the addon code is first loaded during this step, only basic information about the player -- name, class, race and realm -- is available.
When the addon code is first loaded during this step, only basic information about the player -- name, class, race and realm -- is available.