Thread Tools Display Modes
03/02/23, 03:39 PM   #1
moshulu
AddOn Author - Click to view addons
Join Date: Dec 2022
Posts: 6
Post [Video Tutorial] LibAddonMenu and Saved Variables

Hi, everyone! I'm very proud to announce my second tutorial video, entitled "ESO Addon Development: Custom Options and SavedVariables | The Elder Scrolls Online"

Check out the tutorial: https://youtu.be/ndkjro3RUGA

Missed the first tutorial? Check it out here: https://www.youtube.com/watch?v=ZYsr5pVqhso

This tutorial focuses on the integration of LibAddonMenu-2.0 and SavedVariables to create a more-user friendly experience - and allows the options to be remembered when you log out (very important)! Special thanks to @baertram and @wookiefriseur for your feedback, last time. I took it to heart - hopefully this one does you guys justice.

The code can be found here: https://github.com/moshulu/ESOUI-SimpleClock

Hope to see you in-game!

@moshulu
  Reply With Quote
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: 4,913
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

ESOUI » Developer Discussions » Tutorials & Other Helpful Info » [Video Tutorial] LibAddonMenu and Saved Variables

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