View Single Post
08/15/20, 04:25 AM   #37
Marazota
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 257
Originally Posted by sirinsidiator View Post
I believe this can be done in 3 "easy" steps:

1) Update libraries to provide an alternative way of being accessed.
This step shouldn't introduce any major compatibility issues as we still keep everything as is and addons that have not been updated can use LibStub as a method to access the library as before. It's just to pave the way to phase out library access via LibStub in addons
All that should be necessary is to extend the code like this:
Lua Code:
  1. local MAJOR, MINOR = "LibSomething", 3
  2. local lib = LibStub:NewLibrary(MAJOR, MINOR)
  3. if not lib then
  4.     return
  5.     -- already loaded and no upgrade necessary
  6. end
  7.  
  8. LibSomething = lib -- new way to access it without LibStub


In the manifest we also add the "AddOnVersion" and "IsLibrary" directive:
Code:
## AddOnVersion: 3
## IsLibrary: true
That's not strictly necessary until after LibStub has been removed from the lib, but it will ensure that only the newest standalone version is loaded (embedded versions will behave as before) and also move it to the new library section in the addon menu once Elsweyr is released.

2) Find all addons that use a library and change them (or request it) to access dependent libraries via the newly introduced global variable instead of LibStub, remove its files from the addon manifest (so it is no longer embedded) and change from OptionalDependsOn to DependsOn.
Lua Code:
  1. local LS = LibStub("LibSomething")
should become
Lua Code:
  1. lobal LS = LibSomething


3) Update libraries to no longer use LibStub. This will likely cause compatibility issues with any addons that have not been updated in step 2, but at some point we just need to pull the trigger, otherwise LibStub won't ever disappear completely.

Lua Code:
  1. local lib = {}
  2. LibSomething = lib

Let me know what you think. Did I miss anything? Who's on board?
I will start with step 1 in LAMr28 and will introduce the new global variable "LibAddonMenu".
i did step 2 but still got errors
what to change?

need to change something here? commenting libstub line didnt help

Code:
-- INITIALIZATION
-----------------------------------------------------------------------------------------------------------------------------------
function IA_InventoryAssistant:New ( control )
  local inventoryAssistant = ZO_Object.New ( self )
  inventoryAssistant:Initialize ( control )
  return inventoryAssistant
end
-----------------------------------------------------------------------------------------------------------------------------------
function IA_InventoryAssistant:Initialize ( control )
  EH:RegisterForEvent ( self.name, EVENT_ADD_ON_LOADED, function ( event, addonName )
      if addonName ~= self.name then return end
      EH:UnregisterForEvent ( self.name, EVENT_ADD_ON_LOADED )

      self.settings = ZO_SavedVars:NewAccountWide ( "InventoryAssistantSettings", 1, nil, self.defaults )
      --self.async = LibStub( "LibAsync" ):Create ( self.name ) 
      
      self.onlyDuplicates = self.settings.onlyDuplicates
      self.onlyMarkedItems = self.settings.onlyMarkedItems
      self.onlyLoots = self.settings.onlyLoots
      self.groupLoots = self.settings.groupLoots
      self.showCrafted = self.settings.showCrafted
lines i changed now looks like this

Code:
-- LOCAL FUNCTIONS
-----------------------------------------------------------------------------------------------------------------------------------
local EH = LibEventHandler
local menu = LibCustomMenu
local LAM = LibAddonMenu
errors in game

Code:
user:/AddOns/InventoryAssistant/InventoryAssistant.lua:471: attempt to index a nil value
stack traceback:
user:/AddOns/InventoryAssistant/InventoryAssistant.lua:471: in function 'IA_InventoryAssistant:Initialize'
|caaaaaa<Locals> self = [table:1]{}, control = ud </Locals>|r
user:/AddOns/InventoryAssistant/InventoryAssistant.lua:466: in function 'IA_InventoryAssistant:New'
|caaaaaa<Locals> self = [table:2]{version = "1.15.180704-beta", name = "InventoryAssistant"}, control = ud, inventoryAssistant = [table:1] </Locals>|r
user:/AddOns/InventoryAssistant/InventoryAssistant.lua:1499: in function 'IA_InventoryAssistant_OnInitialize'
|caaaaaa<Locals> control = ud </Locals>|r
IA_Main_Initialized:3: in function '(main chunk)'
|caaaaaa<Locals> self = ud </Locals>|r
  Reply With Quote