WoW:Saving variables between game sessions (source)
Revision as of 15:21, 28 November 2007
, 28 November 2007Clarified load sequence.
m (→VARIABLES_LOADED event: minor rewording) |
(Clarified load sequence.) |
||
| Line 7: | Line 7: | ||
* <tt>WTF\Account\ACCOUNTNAME\RealmName\CharacterName\AddOnName.lua</tt> - Per-character settings for each individual AddOn | * <tt>WTF\Account\ACCOUNTNAME\RealmName\CharacterName\AddOnName.lua</tt> - Per-character settings for each individual AddOn | ||
These files are written whenever the UI engine shuts down | These files are written whenever the UI engine shuts down, either when the game is quit, or when you force a UI reload (with <code>/console reloadUI</code>). Like the other .lua scripts for the UI, the SavedVariables scripts are executed when the UI is started and AddOns are loaded. This happens when you first log on, and each time you force a UI reload. | ||
The | The SavedVariables files are executed at different times, depending on their types, and it's important to understand the when they're executed, particularly relative to the <code>ADDON_LOADED</code> and <code>VARIABLES_LOADED</code> events. The sequence is as follows: | ||
* MyAddOn loads | |||
* AddOnName.lua loads and executes | |||
* ADDON_LOADED event fires for MyAddOn | |||
* … other AddOns load … | |||
* SavedVariables.lua loads and executes | |||
* VARIABLES_LOADED event fires | |||
* Player gets control | |||
When the UI engine shuts down, only those variables which have been marked for saving will be written into the <tt>SavedVariables.lua</tt> files. A variable can be written to more than one file (though this is generally ill-advised since it can cause settings to be overwritten later on) | When the UI engine shuts down, only those variables which have been marked for saving will be written into the <tt>SavedVariables.lua</tt> files. A variable can be written to more than one file (though this is generally ill-advised since it can cause settings to be overwritten later on) | ||