View Single Post
12-30-17, 11:11 AM   #20
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Originally Posted by Fizzlemizz View Post
A lot of the "how" your logic might work would depend on if the addon is solely for your own use or not (you did say "I frequently").

You can make a lot of assumtions about the definition of how "useful" an addon is if it is just for your own use.

Some addon configs are seperate addons that are LOD but may be "useful" occaisionally.
Addons that are tagged "LoadWith" might not load every time but might still be "useful".
Every addon that loads by default may not be "useful".

Sorry, it's the devil's advocate in me, you may well have this covered.
Heh, I like playing devil's advocate. I have thought of some of these situations. The LOD and LoadWith I did not.

Do variables created inside a local function need the local?

My thought for the date is compare current addon load state with the savedvariable and update if it is different (i.e. loaded and not loaded). I'll worry about the LOD and LoadWith later. If they are both disabled, do not update the date/time. This will give me a semi accurate idea of when it was last loaded. For the most part, this should work except for what we mentioned.

I'm trying this code for the logic, but I'm not quite getting it right.

Lua Code:
  1. local addonlistdb
  2.  
  3. local function PLAYER_LOGOUT()
  4.     AddonListDB = {}
  5.     local addcount = GetNumAddOns()
  6.     for i = 1,addcount do
  7.         local name, title, notes, loadable, reason, security, newVersion = GetAddOnInfo(i)
  8.         loaded, finished = IsAddOnLoaded(i)
  9.         local dep1, dep2, dep3 = GetAddOnDependencies(i)
  10.         local odep1 = GetAddOnOptionalDependencies(i)
  11.         local ldemand = IsAddOnLoadOnDemand(i)
  12.         if (loaded ~= AddonListDB[i].Loaded) or ((loaded == true) and (AddonListDB[i].Loaded == true)) then
  13.             AddonListDB[i] = {
  14.                 Title=title,
  15.                 Loaded=loaded or false,
  16.                 Dependencies=dep1 or false,
  17.                 OptionalDependencies=odep1 or false,
  18.                 LoadOnDemand=ldemand or false,
  19.                 DateTime=date("%m/%d/%y %H:%M:%S")
  20.             };
  21.         elseif (loaded == nil) and (AddonListDB[i].Loaded) == false then
  22.             AddonListDB[i] = {
  23.                 Title=title,
  24.                 Loaded=loaded or false,
  25.                 Dependencies=dep1 or false,
  26.                 OptionalDependencies=odep1 or false,
  27.                 LoadOnDemand=ldemand or false
  28.             };
  29.         end
  30.     end
  31. end
  32.  
  33. local JWFrame = CreateFrame("Frame");
  34. JWFrame:RegisterEvent("PLAYER_LOGOUT");
  35. JWFrame:SetScript("OnEvent", PLAYER_LOGOUT)
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote