ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   "Cannot find a library instance of ..." (https://www.esoui.com/forums/showthread.php?t=7151)

Lum1on 06/18/17 12:00 AM

"Cannot find a library instance of ..."
 
Hey,

I've played around with some own addons and I just got familiar with LibAddonMenu-2.0 library. On Wiki there were some great instructions and I learned a lot how to use it.

But I don't really understand why two other libraries does not work whatsoever. I'm trying to use LibScroll and libChat2. So here's what I've done:
  • I've extracted LibScroll and libChat2 folders inside my addon's folder (just like I did with LibAddonMenu-2.0)
  • Neither of them adviced to list them into DependsOn or OptionalDependsOn lists inside the manifest so at first I didn't. But because I haven't been able to make it work I've tried in both of them. Problem's still there.
  • I have them listed in my manifest file in a same way I have LibAddonMenu-2.0 (and LibStub) but no luck so far. One thing I do not understand is I don't have LibAddonMenu-2.0 (and LibStub) folders inside any folder called "Libs" but in Lua you have to write that before - why's that? For example, "Libs/LibStub/LibStub.lua" when the path is really "...\AddOns\<ADDON>\LibStub\LibStub.lua"

In my LUA I have the following code (in the very beginning of the file):

Code:

local LibAM = LibStub:GetLibrary("LibAddonMenu-2.0")
local LibS = LibStub:GetLibrary("LibScroll")
local LibC = LibStub:GetLibrary("libChat-1.0")

And no matter what I've tried I still get the error from LibScroll and libChat-1.0. LibAddonMenu-2.0 is working fine, though, and I've managed to create an addon settings page which is working as intended.

Any help here? :o

votan 06/18/17 01:10 AM

There is nothing special with libraries. They are just Lua code as everything else.
Means: The load order matters. => Something, not declared yet, is unknown.

In your manifest LibStub must come first, then all libs you want to use and last comes your main file using them.
Typos in paths are silently ignored.

Show us your manifest.txt.

Lum1on 06/18/17 01:28 AM

Problem solved, thanks votan!

Did not know and nobody ever mentioned it anywhere that you must load libraries before your own LUA and XML files. Did not think the load order matters.

Antikuba 09/07/20 12:14 PM

If you are a simple user from 2020 and have same problem, for example
"user:/AddOns/GearSetsSort/GearSetsSort.lua:328: Cannot find a library instance of "LibAddonMenu-2.0".

where is a fix:

change line in GearSetsSort.lua file
from " local LAM = LibStub('LibAddonMenu-2.0') " to "local LAM = LibAddonMenu2".

Baertram 09/08/20 06:08 AM

Additional information about libraries can be read here, especially why LibStub is obsolete meanwhile and should not be used anymore (where not needed):
https://wiki.esoui.com/Libraries#Lib...ersion_control


All times are GMT -6. The time now is 08:09 AM.

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