ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Need help with loading SavedVariables (https://www.esoui.com/forums/showthread.php?t=1398)

BadVolt 05/07/14 01:00 AM

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

Wobin 05/07/14 01:16 AM

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

BadVolt 05/07/14 01:22 AM

Quote:

Originally Posted by Wobin (Post 7101)
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. :confused:

lyravega 05/07/14 01:34 AM

Could it be ", nil)" at the last part of the variable initialization?

BadVolt 05/07/14 01:35 AM

Found it. :banana:
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 :)

Wobin 05/07/14 01:35 AM

It'll be easier if we can see both the lua file and the addon.txt file

BadVolt 05/07/14 02:05 AM

Quote:

Originally Posted by Wobin (Post 7106)
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.

Garkin 05/07/14 03:53 AM

Quote:

Originally Posted by lyravega (Post 7104)
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.

LilBudyWizer 05/07/14 08:59 AM

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.


All times are GMT -6. The time now is 09:07 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI