View Single Post
03/02/23, 07:46 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,002
Thanks for your next video tutorial, it's appreciated.

My 2 cents:
LibAddonMenu-2.0 added the global variable LibAddonMenu2 with version 26 first. New created addons should thus use the >= tag behind the ## Optional or ## DependsOn entries so that the addons do not load with any "older" LAM version!
Same for other libraries.
Allthough most users will have the newest versions of libraries installed there exist A LOT users using old addons with bundled old libs and thus these old libs could make your addon not work properly. So better check for the newest / needed versions of these libs by using the >= version check tag ending!
-> Read about the >= version checks here at the Wiki:
https://wiki.esoui.com/Addon_manifes...ionalDependsOn
https://wiki.esoui.com/Libraries#.23...ned_integer.3E


And for SavedVariables you should always consider "multi server" gameplay from the beginning of your addon, as many ESO players play on NA and EU megaservers at the same time!

In your SV, if you are using the ZO_SavedVars: wrapper, you can either use the profile parameter or somethign else, and pass in the server name (which the API function GetWorldName() returns as a String).
Not all addons need multi server differences, but many do need (especially if they arerelated to chat, guilds, use date and time, etc.).

Example usage:
Lua Code:
  1. local worldName = GetWorldName()
  2. --Character settings
  3. local charSettings = ZO_SavedVars:NewCharacterId(addonSavedVariablesName, addonSavedVariablesVersion, "Settings", defaults, worldName)
  4.  
  5. --Account wide settings
  6. local accSettings = ZO_SavedVars:NewAccountWide(addonSavedVariablesName, addonSavedVariablesVersion, "Settings", defaults, worldName, nil) --last param is the displayName to use. if left nil it will be automatically replaced with GetDisplayName() result. But if you pass in something "fixed" like "AllAccountsTheSame" you can save your data for all your different @accountNames the same!

You can either use the profile param liek I have done here, for the GetWorldName(), or you could also pass it in at the 3rd param (where I'm using "Settings" in the example).
It just differs in the global SavedVariables table structure in the end.


btw: In your video tut you define "savedvariables = ZO_SavedVars:NewAccountWide" which makes savedvariables a global leaking variable -> it's missing the local up in front ;-) and could be overwriting other addons variables that way. Be carefull with it, especially if these variable names are "non unique" or "common".

Last edited by Baertram : 03/02/23 at 07:55 PM.
  Reply With Quote