Quantcast [open] Are any of the strings from an addon's .txt file available within Lua? - ESOUI
Thread Tools Display Modes
05/18/18, 09:48 AM   #1
ziggr
 
ziggr's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 16
[open] Are any of the strings from an addon's .txt file available within Lua?

Are any of the strings from an addon's .txt file available within Lua?

Specifically, I'd love to reuse some of the strings from WritWorthy.txt:

Code:
## Title: WritWorthy 4.0.6  <-- version here
## Version 4.0.6            <-- and here
## Last Updated: 2018-05-04
## APIVersion: 100022 100023
## Description: Master Writs: calculate material costs and automate crafting.
## Author: ziggr
...
as parameters to LibAddonMenu
Lua Code:
  1. local panelData = {
  2.     type                = "panel"
  3. ,   name                = "WritWorthy"
  4. ,   displayName         = "WritWorthy"
  5. ,   author              = "ziggr"
  6. ,   version             = "4.0.6"   <-- repeated here
  7. ,   registerForRefresh  = false
  8. ,   registerForDefaults = false
  9. }
  10. local panel = LAM2:RegisterAddonPanel(lam_addon_id, panelData)
  Reply With Quote
05/18/18, 10:36 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,108
You can access a number of fields via GetAddonInfo on the addon manager, but the version is not one of them.
There is already a thread on the wishlist asking for that, so you might want to add a comment there.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
05/18/18, 11:38 AM   #3
ziggr
 
ziggr's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 16
Aha! I'd never seen the AddOnManager before.

Thank you!
  Reply With Quote
05/20/18, 03:40 AM   #4
BoarGules
 
BoarGules's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2017
Posts: 27
That's something that I think many of us would like. I have several files that need to contain the version number, not just the .txt file but also the .cmd that creates the zipfile for uploading, etc. This is how I get around that:
  • Have a file Version.lua that contains just one little table with all of this stuff in it.
  • Create templates for .txt and .cmd files, for example myaddon.txt.template.
  • At publication time, generate the .txt and .cmd files from the templates, taking the variables from Version.lua.
  Reply With Quote
05/20/18, 07:47 AM   #5
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,108
Same here. I just use a token in my txt and lua files and then run a build script which replaces the token with the real version before creating a zip archive. Still would be nice if we could use the version from the manifest in the addon code.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
05/21/18, 07:54 AM   #6
ZOS_ChipHilseberg
ZOS Staff!
Premium Member
Yes this person is from ZeniMax!
Join Date: Oct 2014
Posts: 522
The version field is meant to hold an unsigned integer and is used to prevent a lower version of an addon from loading if there is a higher version. We can add an API to return this number, but it would not work with your "4.0.6" example.
  Reply With Quote
05/21/18, 09:00 AM   #7
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,108
Addon authors have been using "## Version: <string>" since launch. Maybe it is not officially supported?
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
05/21/18, 11:12 AM   #8
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 1,741
How are we able to load the same addon twice, with different versions? The foldername would be the same for the addons thus the filenames would replace themselves and the game got no comparison to the addon versions anymore as there is only 1 folder containing the files.

The same for libraries which use libStub already to only load the "newest" version.

Originally Posted by ZOS_ChipHilseberg View Post
The version field is meant to hold an unsigned integer and is used to prevent a lower version of an addon from loading if there is a higher version. We can add an API to return this number, but it would not work with your "4.0.6" example.

Last edited by Baertram : 05/21/18 at 01:31 PM.
  Reply With Quote
05/21/18, 01:25 PM   #9
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 311
Originally Posted by Baertram View Post
How are we able to load the same addon twice, with different versions? The foldername would be the same for the adodns thus the filenames would replace themselves and the game got no comparison to the addon versions anymore as there is only 1 folder containing the files.

The same for libraries which use libStub already to only load the "newest" verison.
Maybe it goes off the ## Name field. However, with the changes to addon detection it would be possible to have the same addon hidden in a folder.
  Reply With Quote
05/21/18, 01:58 PM   #10
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,108
Originally Posted by Dolgubon View Post
Maybe it goes off the ## Name field. However, with the changes to addon detection it would be possible to have the same addon hidden in a folder.
It was always possible to have a manifest in a nested folder, but the game wouldn't load the files.

e.g. this configuration:
Code:
addons/LibAddonMenu/manifest.txt
addons/SomeAddonWithALetterAfterL/LibAddonMenu/manifest.txt
One would expect that LibAddonMenu is loaded from addons/LibAddonMenu, but the game searches all nested folders and then picks the last manifest it found (it's actually a bit more complicated since dependencies also play a role). Because of that it would decide to load the nested manifest in SomeAddonWithALetterAfterL and in the past the standalone version of LAM wouldn't get loaded at all since the paths in the manifest would get treated as relative to the addon root folder.
Now with the changes applied to addon loading, the paths in the manifest are treated relative to the manifest file, which allows us to load nested addons correctly. The AddOnVersion directive comes into play when the game sees more than one version of the same addon. When no version is supplied, it will just pick the last file as explained before, but when we add a version it will always prefer the one with the highest number.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
05/29/18, 06:07 AM   #11
Scootworks
 
Scootworks's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2014
Posts: 214
Originally Posted by sirinsidiator View Post
Addon authors have been using "## Version: <string>" since launch. Maybe it is not officially supported?
i would love to see #APIVersion too!
__________________
EU Server - SŁĄuGhTerHĜuSe
  Reply With Quote

ESOUI » Developer Discussions » Wish List » [open] Are any of the strings from an addon's .txt file available within Lua?

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