ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   SavedVars (https://www.esoui.com/forums/showthread.php?t=7849)

Tarlac 06/08/18 08:48 PM

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.

Rhyono 06/08/18 09:12 PM

I think the easiest thing to do is save account wide, then specify the subtable for each character.

Baertram 06/09/18 01:53 PM

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

Tarlac 06/15/18 04:28 PM

Quote:

Originally Posted by Baertram (Post 35000)
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.

Tarlac 06/15/18 05:15 PM

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.

Baertram 06/16/18 02:12 AM

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.

SDPhantom 06/16/18 09:09 AM

Quote:

Originally Posted by Tarlac (Post 35040)
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.

Tarlac 06/16/18 11:13 AM

Quote:

Originally Posted by SDPhantom (Post 35054)
You can print out a list by iterating through the keys of SCENE_MANAGER.scenes.

Thanks I appreciate it.


All times are GMT -6. The time now is 12:08 AM.

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