Quantcast
WoWInterface - View Single Post - adding a GUI for addon options
View Single Post
06-01-10, 02:24 PM   #15
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,510
Assuming the SavedVariables is set up in your TOC it will automatically load up when the ADDON_LOADED event is called.


For a simplish addon these 3 events should be all you need to use. The PLAYER_LOGOUT event is only really needed if you don't use the saved variables directly but copy them into local variables for ease of access. Just make sure to store them back to the saved variables during this LOGOUT event.
Code:
if event == ADDON_LOADED then
   -- The AddOn's Saved Variables are loaded
   -- Use this event to make sure that the values are valid or set to the default
  -- EG. SavedVariable = SavedVariable or SomeDefaultValue
  -- This basically uses the loaded value or sets the default value if there is no loaded value
elseif event == VARIABLES_LOADED then
   -- Blizzards Saved Variables and CVars etc are loaded
   -- Use this to override what they have done such as positioning of blizz frames and sizing
elseif event == PLAYER_LOGOUT then
   -- This is where you want to make sure that your saved variables are set 
   -- as this is the last port of call before it stores the values in the WTF file
   -- You can also use this similarly to the ADDON_LOADED event where you set the default if a value doesn't exist as a double check that the values didn't get nulled during process.
   -- EG. SavedVariable = SavedVariable or SomeDefaultValue
end
__________________
  Reply With Quote