Quantcast Can I access SavedVariables of other addon - ESOUI
Thread Tools Display Modes
01/20/18, 04:31 AM   #1
Haaxor1689
 
Haaxor1689's Avatar
Join Date: Dec 2017
Posts: 9
Can I access SavedVariables of other addon

Hi, I would like to do an extension for someone else's addon and for that I would need to acces it's SavedVariables without modifying that addon. Is this possible? Thanks.
  Reply With Quote
01/20/18, 04:57 AM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 454
Originally Posted by Haaxor1689 View Post
Hi, I would like to do an extension for someone else's addon and for that I would need to acces it's SavedVariables without modifying that addon. Is this possible? Thanks.
The answer is as most times in life: Yes, with a big but:
The saved variables are global, so yes you can, but:
1. You have to wait until the other addons are loaded. One way to do this is to make your addon
## OptionalDependsOn: in the manifest.txt.
2. Reading is ok, but for changing properties, you have check what the code does, which normally change them.
__________________
@votan73 (EU - megaserver)
  Reply With Quote
01/20/18, 05:07 AM   #3
Haaxor1689
 
Haaxor1689's Avatar
Join Date: Dec 2017
Posts: 9
Originally Posted by votan View Post
The answer is as most times in life: Yes, with a big but:
The saved variables are global, so yes you can, but:
1. You have to wait until the other addons are loaded. One way to do this is to make your addon
## OptionalDependsOn: in the manifest.txt.
2. Reading is ok, but for changing properties, you have check what the code does, which normally change them.
Thanks for the reply. I only need to read those values and I already have those addons in `## DependsOn:`. I'm still getting null tho, how exactly should I load those values? Do I need to have the files I want to load in `## SavedVariables:`? Do I simply load them with `ZO_SavedVars:New`?

This is my almost first attempt at creating addon for eso and since the documentation is pretty lacking I'm not sure why it isn't working.
  Reply With Quote
01/20/18, 05:42 AM   #4
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 454
Originally Posted by Haaxor1689 View Post
Thanks for the reply. I only need to read those values and I already have those addons in `## DependsOn:`. I'm still getting null tho, how exactly should I load those values? Do I need to have the files I want to load in `## SavedVariables:`? Do I simply load them with `ZO_SavedVars:New`?

This is my almost first attempt at creating addon for eso and since the documentation is pretty lacking I'm not sure why it isn't working.
You can have a look at http://www.esoui.com/downloads/info9...eTooltips.html. There I read the values from QuickEnchanter, if present.

Basically, due to DependsOn, the AddonLoaded callback is called for the other addon first. So once the addonName is the name of the other addon, you can use the SavedVar as if it would be yours.
You just have to use the same ZO_SavedVars method as the other addon, just without any defaults.
__________________
@votan73 (EU - megaserver)
  Reply With Quote
01/20/18, 06:08 AM   #5
Haaxor1689
 
Haaxor1689's Avatar
Join Date: Dec 2017
Posts: 9
Originally Posted by votan View Post
You can have a look at http://www.esoui.com/downloads/info9...eTooltips.html. There I read the values from QuickEnchanter, if present.

Basically, due to DependsOn, the AddonLoaded callback is called for the other addon first. So once the addonName is the name of the other addon, you can use the SavedVar as if it would be yours.
You just have to use the same ZO_SavedVars method as the other addon, just without any defaults.
Thanks a lot. I forgot that those variables are global and when my addon initializes those dependencies are already initialized so I can just read the savedVariables from their global.

And for the rewriting of savedVariables, can I just use that reference (I assume that it's just a reference) to write to their savedVariables?
  Reply With Quote
01/20/18, 06:12 AM   #6
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 1,662
You maybe could use the global savedvars of the other addon. But you need to check if they are using acocunt wide or character saved avrs, using the charname as key (ZO_SavedVars:New) or the new method with the charId (ZO_SavedVars:NewCharacterId) which is rename save.

And messing around with other addon's savedvars won't work properly if the other addon changes them back upon reloadui somehow from it's internal savedvars.
The addon loads the savedvars into lest's say local settings 0 ZO_SavedVars:new(...).
You change the global vars now from your addon in this addon's savedvars.

Reloadui -> The adodnw rites it's local settings to the savedvars and overwrites your changed settings int he global SV again.
  Reply With Quote
01/20/18, 06:32 AM   #7
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 454
Originally Posted by Baertram View Post
You maybe could use the global savedvars of the other addon. But you need to check if they are using acocunt wide or character saved avrs, using the charname as key (ZO_SavedVars:New) or the new method with the charId (ZO_SavedVars:NewCharacterId) which is rename save.

And messing around with other addon's savedvars won't work properly if the other addon changes them back upon reloadui somehow from it's internal savedvars.
The addon loads the savedvars into lest's say local settings 0 ZO_SavedVars:new(...).
You change the global vars now from your addon in this addon's savedvars.

Reloadui -> The adodnw rites it's local settings to the savedvars and overwrites your changed settings int he global SV again.
The ZO_SavedVars is a wrapper. Even if you have two wrapper within two addons, the common, global savedVariable is used.
__________________
@votan73 (EU - megaserver)
  Reply With Quote
01/20/18, 11:39 AM   #8
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,022
Please avoid if you didn't contacted the author, especially if you change the sv.

Lua Code:
  1. TheNameOfTheVarInMetaFile[GetDisplayName()]

after it's either ["Defaults$"] or charname or the char id depending on how the addon save the data.
__________________
Obsessive Compulsive Coder

My little french Guild: Cercle de l'Eveil
  Reply With Quote
01/20/18, 02:22 PM   #9
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,086
I agree with Ayantir. Just because it's possible doesn't mean it is a good idea.
Changing the save data of another addon can cause issues for both addons. When the original addon changes and something breaks due to you changing their data, either the author of it will get reports for some bug that has nothing to do with his addon or you will get reports because your addon won't work anymore.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
01/20/18, 04:04 PM   #10
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 1,662
Maybe contact the author so he provides a global function in his addon which you can use to update the data properly in both addons.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Can I access SavedVariables of other addon

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