ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Need help with OptionalDependsOn (https://www.esoui.com/forums/showthread.php?t=7795)

BoarGules 05/25/18 11:01 AM

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

Rhyono 05/25/18 11:27 AM

You're calling LAM from your main lua file and you've set your main file to load BEFORE LAM, so you're going to run into an issue.

BoarGules 05/26/18 02:26 AM

Thank you. I didn't know that the order of the modules in the .txt file was significant. So it was a typo, of a sort.

Dolgubon 05/26/18 06:49 PM

Quote:

Originally Posted by BoarGules (Post 34779)
Thank you. I didn't know that the order of the modules in the .txt file was significant. So it was a typo, of a sort.

The order of the files in the.txt determines the load order of the files. When a file is loaded it'll run all the code there. If some code is within a function, unless the function is called it won't be run, but the function will be created. The event for add-on initialized is fired anytime an add-ons files are all loaded. Thus, you can put the LibStub file inside that and it won't matter where in the manifest libstuf is.


All times are GMT -6. The time now is 01:02 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI