View Single Post
05/25/18, 11:01 AM   #1
BoarGules
 
BoarGules's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2017
Posts: 34
Need help with OptionalDependsOn

My addon specifies

## OptionalDependsOn: LibAddonMenu-2.0

and the code does this:

LAM = LibStub('LibAddonMenu-2.0')

With only my addon loaded, this line throws the mystifying exception function expected instead of nil. I say mystifying because if LibStub is not defined then the exception I would expect is attempt to call local/global LibStub (a nil value). I can make the untrapped exception go away by wrapping the assignment in a pcall() but all that does is silence the message.

With LibAddonMenu-2.0 loaded (or any other add-on that uses it) then everything works as expected. So it appears that this bit of the addon has all along been been working only by accident because some other addon had already successfully loaded the library I want.

My question is, what could I be doing wrong? My instincts suggest a typo, but if it is, I just can't see it. There are only 2 lines of code to look at, and 16 filenames to check (LibStub, LibAddonMenu and its 14 controls). Here they are:

lib/LibStub/LibStub.lua
lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua
lib/LibAddonMenu-2.0/controls/button.lua
lib/LibAddonMenu-2.0/controls/checkbox.lua
lib/LibAddonMenu-2.0/controls/colorpicker.lua
lib/LibAddonMenu-2.0/controls/custom.lua
lib/LibAddonMenu-2.0/controls/description.lua
lib/LibAddonMenu-2.0/controls/divider.lua
lib/LibAddonMenu-2.0/controls/dropdown.lua
lib/LibAddonMenu-2.0/controls/editbox.lua
lib/LibAddonMenu-2.0/controls/header.lua
lib/LibAddonMenu-2.0/controls/iconpicker.lua
lib/LibAddonMenu-2.0/controls/panel.lua
lib/LibAddonMenu-2.0/controls/slider.lua
lib/LibAddonMenu-2.0/controls/submenu.lua
lib/LibAddonMenu-2.0/controls/texture.lua
  Reply With Quote