Thread Tools Display Modes
06/25/14, 04:29 PM   #1
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
[implemented] Programmatical way to get the API version

There are cases where I would like to get the API version to make checks with in my code. In specific I need a way to detect if the API version changed and manaully reset the stored data to defaults then.

My Addon UTC can store the Categoreis that are enabeled for each tab in each chat container. I asume the current code will be good for a few more years, as there is no even remotely botusable function in the chat part I touch and I use Loops based on #Table and GetNum Functions.

However every time the API version changes the order of chat categories might change. So at least in the first start after a version change I have to reset the settings & data. Doing this via the existing Saved Var Versioning system is not viable (or nessesary for that matter).

All I need is a function "getAPIVersion()" that returns a int or string with the version (either works for me. Only doing an inequality check). Asuming it was not added with the 1.2.3 patch.
 
06/25/14, 05:12 PM   #2
farangkao
 
farangkao's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 59
Post

As far as i know it's not there, however...

you can use the trick to check for new Functions or Globals (introduced in a certain version)

for example:
Lua Code:
  1. function GetAPIVersion()
  2.   if GetTradingHouseListingItemLink then return 10007 end  
  3.   return 10003
  4. end
I've not tested this example code (just in my mind), basically if a function doesn't exists it returns nil, and therefore the "if" statement fails and goes to the next line.
 
06/25/14, 06:29 PM   #3
Halja
 
Halja's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 111
I don't think so. Where I look is in the file AddOnSettings.txt. It's in the same folder as UserSettings and the parent of the Addons folder for the game. The first line declares the API version. It could be in a cVar the new EULA for Addons are. (ViewedAddOnEULAVersion and AcceptedAddOnEULAVersion) Those are exposed in the UserSettings file.
--halja
 
06/26/14, 05:10 AM   #4
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by farangkao View Post
As far as i know it's not there, however...

you can use the trick to check for new Functions or Globals (introduced in a certain version)

for example:
Lua Code:
  1. function GetAPIVersion()
  2.   if GetTradingHouseListingItemLink then return 10007 end  
  3.   return 10003
  4. end
I've not tested this example code (just in my mind), basically if a function doesn't exists it returns nil, and therefore the "if" statement fails and goes to the next line.
That is a way if I know of a specific change beforehand (because it was on the PTS). But it requires me to design the code for each new version.
Better then just deletion everytime _VERSION (the build version of the client) changed.

Last edited by zgrssd : 06/26/14 at 05:13 AM.
 
06/26/14, 05:50 AM   #5
Shinni
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 167
not a perfect way but this should work:
Lua Code:
  1. local AddOnManager = GetAddOnManager()
  2. for i = 1, AddOnManager:GetNumAddOns() do
  3.         local name, title, author, description, enabled, state, isOutOfDate = AddOnManager:GetAddOnInfo(i)
  4.     if title == "myaddonname" then
  5.         if isOutOfDate then
  6.             --api change!
  7.         end
  8.     end
  9. end
it doesn't retrieve the api version but if the addon was uptodate, it will know if there was an API change.
 
06/26/14, 08:03 AM   #6
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by Shinni View Post
not a perfect way but this should work:
Lua Code:
  1. local AddOnManager = GetAddOnManager()
  2. for i = 1, AddOnManager:GetNumAddOns() do
  3.         local name, title, author, description, enabled, state, isOutOfDate = AddOnManager:GetAddOnInfo(i)
  4.     if title == "myaddonname" then
  5.         if isOutOfDate then
  6.             --api change!
  7.         end
  8.     end
  9. end
it doesn't retrieve the api version but if the addon was uptodate, it will know if there was an API change.
Very nice idea. Just need to store if this OOD state was already detected before.

Since that is propably better to be left to a library to gather all this data once, I made it a Feature Request for OrangUtils.
But I am going to test it a bit via a button. If he thinks it is out of scope, I just make it library myself.
 

ESOUI » Developer Discussions » Wish List » [implemented] Programmatical way to get the API version


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