Thread: Saved Variables
View Single Post
08-30-12, 01:19 PM   #2
Jarod24
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 66
All variables that you want to save must be named in you .TOC file under the SavedVariables section
Toc file info: http://www.wowwiki.com/TOC_format

Blizzard saves the settings in a lua file with you addon name in the WTF folder.

..
## SavedVariables: MyVarA, MyVarB
## SavedVariablesPerCharacter: somePercharVariable
Blizzard will load and replace the variable with the saved settings.
There is a few events to tell you when this has happened. It will be done loading when ADDON_LOADED has fired.


I suggest using a table and save settings inside the table like keys. That way you minimize what you need to change when you add more settings or even remove them.

maybe something like this. just a suggestion, but its not needed.

Lua Code:
  1. MyAddonSettings = {};
  2. MyAddonSettings["Debug"] = true;
  3. MyAddonSettings["Setting1"] = false;
  4. MyAddonSettings["Playername"] = "Bob";

there are also some libraries (ace?) to do this for you.
__________________
Author of IfThen, Links in Chat
  Reply With Quote