Thread Tools Display Modes
04/03/14, 05:40 PM   #1
Tingle0x539
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
ZO_SavedVars:NewAccountWide() not saving

The issue is that the variable will not save, its stays 0.
Any ideas?

So far I have been able to find out that the file is created with the default values if they are specified, then neither loading vales or saving them works, as if it could not read or write to the file. I checked permissions, the file has r/w for everyone.

Doing
Lua Code:
  1. for index, param in pairs(TCC.settings) do
  2.     CHAT_SYSTEM:AddMessage(index..": "..tostring(param))
  3. end
prints out
Lua Code:
  1. GetInterfaceForCharacter: function: 5A559658
Inside my .txt file I have:
Lua Code:
  1. ## SavedVariables: TCC_SV
Inside my .xml I have:
Lua Code:
  1. <OnInitialized>
  2.     TCC.OnInitialized()
  3. </OnInitialized>
Inside my lua file I have:
Lua Code:
  1. TCC.settings = {
  2.     var = 0
  3. }
  4.  
  5. function TCC.OnInitialized()
  6.     TCC.settings = ZO_SavedVars:NewAccountWide("TCC_SV", 1, nil, TCC.settings)
  7.     TCC.settings.var = 1
  8. end
The AddOn's saved var lua file is created just fine inside the \SavedVariables\ folder with this content:
Lua Code:
  1. TCC_SV =
  2. {
  3.     ["Default"] =
  4.     {
  5.         ["@AccountName"] =
  6.         {
  7.             ["$AccountWide"] =
  8.             {
  9.                 ["var"] = 0,
  10.                 ["version"] = 1,
  11.             },
  12.         },
  13.     },
  14. }

Last edited by Tingle0x539 : 04/03/14 at 06:10 PM.
  Reply With Quote
04/03/14, 06:10 PM   #2
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Try another way ..


TCC.defaults = {
var = 0
}

TCC.settings = {
var = 0
}

function TCC.OnInitialized()
TCC.settings = ZO_SavedVars:NewAccountWide("TCC_SV", 1, nil, TCC.defaults)
TCC.settings.var = 1
end

Hopefully that will make it work.
  Reply With Quote
04/03/14, 06:23 PM   #3
Tingle0x539
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
Doesn't work, what I did was deleted the saved var file, restarted the game, set the value to 10, reloaded the UI, now the saved var file has it set to 10. Then I reloaded the UI and the value it loads is 0, and any change to it does not save.

It's seems that it created the file once with the current set value and then never touches it again... The initial save is the only one that counts.

Edit: Ok I got it to work now, for some reason calling ZO_SavedVars:NewAccountWide() in OnInitialized() is to early. By calling it later, for example through the event EVENT_ADD_ON_LOADED, it works as intended.

Last edited by Tingle0x539 : 04/03/14 at 07:00 PM.
  Reply With Quote
04/03/14, 07:00 PM   #4
Mitazaki
 
Mitazaki's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
Gimme a mo while I finish what I'm working on, got something that should help.
  Reply With Quote
04/03/14, 07:28 PM   #5
Tingle0x539
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
Originally Posted by Mitazaki View Post
Gimme a mo while I finish what I'm working on, got something that should help.
Check my last reply, I edited it, figured it out and mentioned my result. But thanks for the planned effort.
  Reply With Quote
04/03/14, 07:45 PM   #6
Mitazaki
 
Mitazaki's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
heh no problem, just finished a developer addon that shows how to save / load vars.


Made a demo addon to simply show how to work with variables, maybe it will help others.
http://www.esoui.com/downloads/fileinfo.php?id=116

Last edited by Mitazaki : 04/03/14 at 08:14 PM. Reason: Prevent double post
  Reply With Quote
04/04/14, 03:40 AM   #7
Vuelhering
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 169
Originally Posted by Tingle0x539 View Post
Edit: Ok I got it to work now, for some reason calling ZO_SavedVars:NewAccountWide() in OnInitialized() is to early. By calling it later, for example through the event EVENT_ADD_ON_LOADED, it works as intended.
Yeah, I remember seeing something in the example in the wiki about it not existing until that event.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » ZO_SavedVars:NewAccountWide() not saving


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