Thread Tools Display Modes
02/25/18, 08:16 AM   #1
BoarGules
 
BoarGules's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2017
Posts: 34
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?
  Reply With Quote
02/25/18, 09:27 AM   #2
Shinni
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 167
GetWorldName() returns the server.
  Reply With Quote
02/25/18, 10:46 AM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
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)
  Reply With Quote
02/25/18, 07:17 PM   #4
BoarGules
 
BoarGules's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2017
Posts: 34
Thank you both.

I do remember wondering what I would ever use the namespace parameter of the NewAccountWide constructor for.
  Reply With Quote
02/26/18, 03:27 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
You can ues it to store data of your addon, for different purposes, like this
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.
  Reply With Quote
02/26/18, 04:18 AM   #6
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 408
I'd have to double check but I think you can use it for system wide settings too.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Can an addon find out which server it is running on?

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