View Single Post
04/24/14, 08:55 PM   #3
archpoet
Cunning Linguist
 
archpoet's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 19
I've seen several other add-on authors sorely over complicate the SavedVars process, so hopefully I can help.

Basically, what i do in my add-ons is define a master table for all the data that a) I need default values for and b) want to save after reload. Then in my init function I setup the table:

Code:
	A.saved = {
		["addon_visible"] = true,
		["addon_orientation"] = 'v',
		["open_menu_alpha"] = 0.25,
                ["super_important_data"] = {},
       }
Then I load the same object.table as the default to the ZO_SavedVars:NewAccountWide() method.

Code:
A.saved = ZO_SavedVars:NewAccountWide( "Addon_SavedVariables", A.version, "saved", A.saved )
*Then* I do lookups and processing against what might have been saved last run, without changing any of the code that would likewise check the default values, (had nothing been changed.)

Sure, granted, there are reasons to keep separate SavedVariables.. but most of our projects don't really meet the criteria for needing to.

Hope this helps!

P.S. LAM syntax looks correct on first glance to me!
  Reply With Quote