View Single Post
08/11/14, 08:19 PM   #17
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Randactyl View Post
I've seen this mentioned a couple of times. How does one avoid ZO_SavedVars in the first place?
You can directly access saved variables table defined in manifest (.txt):

Code:
## SavedVariables: MyAddon_SavedVariables
Lua Code:
  1. local savedVars
  2. local defaults = {
  3.     key1 = "value1",
  4.     key2 = "value2",
  5. }
  6.  
  7. EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_ADD_ON_LOADED,
  8.     function(event, addon)
  9.         if addon ~= "MyAddon" then return end
  10.         EVENT_MANAGER:UnregisterForEvent("MyAddon", event)
  11.  
  12.         MyAddon_SavedVariables = MyAddon_SavedVariables or defaults
  13.         savedVars = MyAddon_SavedVariables
  14.     end)

As an example check Wykkyd's or Seerah's addons.
  Reply With Quote