WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Issue with LibDBIcon and not seeing Ace3 preference database (https://www.wowinterface.com/forums/showthread.php?t=56775)

Buran 10-07-18 07:48 PM

Issue with LibDBIcon and not seeing Ace3 preference database
 
Hi everyone!

Error I'm fighting:

Code:

Interface\AddOns\<addon>\minimap.lua:43: attempt to index field 'db' (a nil value)
I'm declaring LDB support -- which was very easy to add and works well with both text and icon based display -- like this:

Code:

LDB          = LibStub:GetLibrary("LibDataBroker-1.1")
DBIcon        = LibStub("LibDBIcon-1.0")

and


Code:

Me.LDBButton = LDB:NewDataObject(LDBLongLabel, {
        type          = "launcher",
        icon          = "Interface\\Icons\\inv_misc_dice_01",
        label        = LDBShortLabel,
        text          = LDBShortLabel,
        tocname      = MyTOCName,
        OnClick      = function(clickedframe, button) Me.HandleLDBButtonClick() end,
        OnTooltipShow = function(tooltip)
                Me.UpdateFDRLauncherTooltip()
                tooltip:SetText(LDBLongLabel)
                tooltip:AddLine(Me.UpdateFDRLauncherTooltip())
        end,
})

where LDBLongLabel is a string containing the addon's 'pretty' name (with spaces). LDBShortLabel is another string containing an abbreviated form of the addon's name, and is what shows up in ElvUI's datatext panels in my minimap. Similarly, MyTOCName is a string containing the addon's name with no spaces (the name of its folder, etc).

Guild mates who have installed the addon in icon-based LDB packages see the icon just fine.

Then, I try to offer a minimap button as well:

Code:

DBIcon:Register(LDBLongLabel, Me.LDBButton, Me.db.global.MiniMapButton)
This fails with the error at the top of this post -- that's the troublesome line the error stack is calling out. The AceDB database looks like this:

Code:

Me.defaults = {
        profile = {
                (a bunch of defaults for UI, etc).
                },
        };
        global = {
                MiniMapButton = {};
        };
}

as a working addon using this code declared it that way; I've also tried pre-declaring the key
Code:

hide=true
with no difference. It's hung up on not being able to see the database. As far as I can tell, the item declarations match. I'm not sure what I'm missing, but it's probably something similar. Can someone familiar with LibDBIcon be of help?

For now, everything works fine with the DBIcon declaration taken out, so I've done that.

Rilgamon 10-07-18 09:09 PM

Probably your db is declared later in the loading process.
Make sure to delay the creation of the icon until your db is created.


All times are GMT -6. The time now is 11:51 PM.

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