Quantcast SavedVars - ESOUI
Thread Tools Display Modes
06/08/18, 08:48 PM   #1
Tarlac
 
Tarlac's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2018
Posts: 9
SavedVars

Hello Folks.

I am creating an addon and I have run into a little issue. What I am trying to do is access the data in my saved file and display it on which ever character is logged in. I can access my current characters data fine but I am unsure how to load up the values from my other characters. Here is a simple example..


Lua Code:
  1. MyAddonSavedVariables =
  2. {
  3.     ["Default"] =
  4.     {
  5.         ["@Tarlac"] =
  6.         {
  7.             ["Tarlac Sorc"] =
  8.             {
  9.                 ["OffsetX"] = 1274,
  10.                 ["OffsetY"] = 378,
  11.                 ["name"] = "Tarlac Sorc",
  12.                 ["gold"] = 337,
  13.                 ["version"] = 2,
  14.             },
  15.             ["Tarlac Night"] =
  16.             {
  17.                 ["OffsetX"] = 1354,
  18.                 ["OffsetY"] = 155,
  19.                 ["name"] = "Tarlac Night",
  20.                 ["gold"] = 9400,
  21.                 ["version"] = 8,
  22.             },
  23.             ["Tarlac Ramos"] =
  24.             {
  25.                 ["OffsetX"] = 483,
  26.                 ["OffsetY"] = 675,
  27.                 ["version"] = 2,
  28.                 ["gold"] = 21853,
  29.                 ["name"] = "Tarlac Ramos",
  30.             },
  31.         },
  32.     },
  33. }

What I am trying to do is just create a string from this data that I can display on screen.
The string would be something like

Tarlac Sorc = 337
Tarlac Night = 9400
Tarlac Ramos = 21853

The I would display this data in my addon. I can access my current character, but I have not figured out how to access the other characters. Does anyone have any suggestions on where I would begin?

Thanks. Tarlac.
  Reply With Quote
06/08/18, 09:12 PM   #2
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 427
I think the easiest thing to do is save account wide, then specify the subtable for each character.
  Reply With Quote
06/09/18, 01:53 PM   #3
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 1,592
First save your non accountwide data by help of the unique char id, instead of using the old way by their name! Names can change, ids wont.

Then you are able to access your savedvars via their global variable MyAddonSavedVariable. Your account name will be GetDisplayName(). Just do something like local sv = MyAddonSavefVariable['Default'][GetDisplayName()].
For uniqueCharId, charSavedVars in pairs(sv) do
d(charSavedVars["OffsetX"])
End
  Reply With Quote
06/15/18, 04:28 PM   #4
Tarlac
 
Tarlac's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2018
Posts: 9
Originally Posted by Baertram View Post
First save your non accountwide data by help of the unique char id, instead of using the old way by their name! Names can change, ids wont.

Then you are able to access your savedvars via their global variable MyAddonSavedVariable. Your account name will be GetDisplayName(). Just do something like local sv = MyAddonSavefVariable['Default'][GetDisplayName()].
For uniqueCharId, charSavedVars in pairs(sv) do
d(charSavedVars["OffsetX"])
End
Yes Thank you Baertram, I was able to get this working. It took me a couple of days of researching, but I finally found out what you were talking about. ZO_SavedVars:NewCharacterIdSettings is what I finally used then was able to cycle through just as you said. Many thanks!!

Tarlac.
  Reply With Quote
06/15/18, 05:15 PM   #5
Tarlac
 
Tarlac's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2018
Posts: 9
Addon showing during scene change

OK I have almost finished but am running into a small little issue. I only want my addon to be displayed when the normal scene is up . I found command to add as fragment
Lua Code:
  1. local fragment = ZO_SimpleSceneFragment:New(CashierWindow)
  2. HUD_UI_SCENE:AddFragment(fragment)
and this works if it was to be only the cursor scene. I am not sure what the scene names are, is there a listing of them? Or does anyone know what scene is the main scene so like when you open up your map for example the addon disappears. Then comes back after you close map.

Thanks Tarlac.
  Reply With Quote
06/16/18, 02:12 AM   #6
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 1,592
Check my addon FCOStarveStop. Somewhere at the events (I think event_add_on_loaded) there is the code to register a new scene fragment for hud and/or hud_ui + the callback function for the OnStateChanged event, which shows/hides the toplevel control.

Hope it helps.
  Reply With Quote
06/16/18, 09:09 AM   #7
SDPhantom
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 13
Originally Posted by Tarlac View Post
I am not sure what the scene names are, is there a listing of them?
You can print out a list by iterating through the keys of SCENE_MANAGER.scenes.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
06/16/18, 11:13 AM   #8
Tarlac
 
Tarlac's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2018
Posts: 9
Originally Posted by SDPhantom View Post
You can print out a list by iterating through the keys of SCENE_MANAGER.scenes.
Thanks I appreciate it.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » SavedVars

Thread Tools
Display Modes

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