Thread Tools Display Modes
05/07/14, 01:00 AM   #1
BadVolt
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 74
Need help with loading SavedVariables

Hi guys. Have a little problem with loading my saved vars.
Looks like saved vars are always replaced with their default values, but values I save to saved variables are saved normally. Just can't load. Any ideas how to fix it? Loading method is below.

Lua Code:
  1. -- initialize
  2. function IRY:Initialize(self)
  3.     debug("Initialize called")
  4.     self.control=self
  5.  
  6.     local default_playerDatabase={
  7.         data={},
  8.         index={}
  9.     }
  10.  
  11.     local default_params={
  12.         counter = 0
  13.     }
  14.  
  15.     self.playerDatabase = ZO_SavedVars:NewAccountWide("IRY_SavedVars", version, "playerDatabase", default_playerDatabase, nil)
  16.     self.params = ZO_SavedVars:NewAccountWide("IRY_SavedVars", version, "params", default_params, nil)
  17. end
  Reply With Quote
05/07/14, 01:16 AM   #2
Wobin
 
Wobin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 78
What are you setting the variable 'version' to?

If you're not, and it's passing through nil, then it'll always replace the SV with a fresh set.

Set the version to 1, and it will save
  Reply With Quote
05/07/14, 01:22 AM   #3
BadVolt
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 74
Originally Posted by Wobin View Post
What are you setting the variable 'version' to?

If you're not, and it's passing through nil, then it'll always replace the SV with a fresh set.

Set the version to 1, and it will save
It is variable. 0.1 for me now. But thanks for info about 'nil', nice to know.

Interesting observation: If I load these values after my addon loaded, they are loaded fine.
  Reply With Quote
05/07/14, 01:34 AM   #4
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
Could it be ", nil)" at the last part of the variable initialization?
  Reply With Quote
05/07/14, 01:35 AM   #5
BadVolt
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 74
Found it.
My addon initialize was triggered from XML. I changed it to LUA and it works fine now.

Looks like there's a slight difference in way of initializing your addon. Lesson for me
  Reply With Quote
05/07/14, 01:35 AM   #6
Wobin
 
Wobin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 78
It'll be easier if we can see both the lua file and the addon.txt file
  Reply With Quote
05/07/14, 02:05 AM   #7
BadVolt
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 74
Originally Posted by Wobin View Post
It'll be easier if we can see both the lua file and the addon.txt file
Addon GitHub is here, if you are interested.
  Reply With Quote
05/07/14, 03:53 AM   #8
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by lyravega View Post
Could it be ", nil)" at the last part of the variable initialization?
The last part is profile that should be string or nil, that is not an issue.
  Reply With Quote
05/07/14, 08:59 AM   #9
LilBudyWizer
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 32
It's risky doing much of anything prior to addon load. There are, I believe, four ZO_ addons that load first. They are defined, their files load first, but who knows how they function. Zo_SavedVars seems a prime example. It exists, you can call it, you don't get any errors, but the data it uses isn't there yet so it doesn't behave correctly until those ZO_ addons load. Using the API prior to addon load is at your own risk. Who knows the state of the game, what data is populated from the server yet or not and such. Creating controls is strictly client and it doesn't rely upon server data to do that. The data displayed by a control may be a whole different story though.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Need help with loading SavedVariables


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off