ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Can an addon find out which server it is running on? (https://www.esoui.com/forums/showthread.php?t=7648)

BoarGules 02/25/18 08:16 AM

Can an addon find out which server it is running on?
 
I have a user who switches between the EU and the NA servers and remarks that saved variables are being carried over from the one server to the other, which isn't really surprising, since they live in live\SavedVariables, which is used irrespective of which server the client is running against. There is a separate folder for the PTS, and there used to be a separate folder for the EU server (liveeu), but that went away over 2 years ago.

This is inconvenient because the addon saves things that relate to guild membership.

Is there a way for an addon to find out which server it is running on so that the code can know to invalidate the stored data?

Shinni 02/25/18 09:27 AM

GetWorldName() returns the server.

Baertram 02/25/18 10:46 AM

As the savedvariables is automatically saving the data you can use e.g. the additional "sub key" in the savedvars for the servername.

If you are using non-accountwide settings:
Be sure to switch from ZO_SAvedVars:New to ZO_SavedVarsNewCharacterId too so renames of characters are handled too. The savedvars will be saved with the id of the char and not the name any more!

Lua Code:
  1. local savedVariables = ZO_SavedVars:NewCharacterId("KeyForTheVars", variableVersion, "ServerNameHere", DefaultValues)

BoarGules 02/25/18 07:17 PM

Thank you both.

I do remember wondering what I would ever use the namespace parameter of the NewAccountWide constructor for.

Baertram 02/26/18 03:27 AM

You can ues it to store data of your addon, for different purposes, like this :D
Or e.g. to split your savedvars into "general fixed settings" and "floating data during gameplay" if the adodn needs base setitngs and collected data form inventories e.g.

e.g. "base data": save settings acocunt wide or per character?
"settings": accout wide/character settings for the addon
"floating data": marker icons, inventory information, worldmap positions, etc.

Dolgubon 02/26/18 04:18 AM

I'd have to double check but I think you can use it for system wide settings too.


All times are GMT -6. The time now is 05:21 AM.

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