StafordDev |
11-16-19 07:24 AM |
Creating AddOn minimap button using LibDBIcon
As a developer of PoisonCharges addon ( https://www.curseforge.com/wow/addons/poisoncharges) I wanted to update it to the latest WoW Classic version 1.13.2. But I ran into a number of problems trying to remake a minimap button. I tried to use LibDBIcon but can't make it to work because I never worked with libraries when developing addons for WoW.
What I did:
1) copied following libraries to Interface/Addons/PoisonCharges/Libs folder: AceDB-3.0, CallbackHandler-1.0, LibDataBroker-1.1, LibDBIcon-1.0, LibSharedMedia-3.0, LibStub;
2) tried to load them with following XML code (embeds.xml):
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<!--@no-lib-strip@-->
<Script file="Libs\LibStub\LibStub.lua"/>
<Include file="Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
<Include file="Libs\AceDB-3.0\AceDB-3.0.xml"/>
<!--@end-no-lib-strip@-->
<Script file="Libs\LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
<!--@no-lib-strip@-->
<Script file="Libs\LibSharedMedia-3.0\LibSharedMedia-3.0.lua"/>
<Script file="Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua"/>
<!--@end-no-lib-strip@-->
</Ui>
3) of course added it to .toc file:
Code:
...
PoisonCharges.lua
PoisonCharges.xml
embeds.xml
4) put following code into OnEvent function (which fires only once when the addon is loaded):
Code:
local LDB = LibStub("LibDataBroker-1.1", true)
local LDBIcon = LDB and LibStub("LibDBIcon-1.0", true)
if LDB then
local PC_MinimapBtn = LDB:NewDataObject("PoisonCharges", {
type = "launcher",
text = "PoisonCharges",
icon = "Interface\\AddOns\\PoisonCharges\\media\\PoisonCharges_Icon",
OnClick = function(_, button)
if button == "LeftButton" then PC_SettingsToggle() end
end,
OnTooltipShow = function(tt)
tt:AddLine("PoisonCharges")
tt:AddLine("|cffffff00Click|r to open the PoisonCharges settings window.")
end,
})
if LDBIcon then
LDBIcon:Register("PoisonCharges", PC_MinimapBtn, PC_MinimapPos) -- PC_MinimapPos is a SavedVariable which is set to 90 as default
end
end
5) and this is the error I get:
Code:
Message: ...s\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:314: attempt to index local 'db' (a number value)
Time: Sat Nov 16 16:14:49 2019
Count: 1
Stack: ...s\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:314: attempt to index local 'db' (a number value)
...s\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:314: in function `Register'
Interface\AddOns\PoisonCharges\PoisonCharges.lua:52: in function `PoisonCharges_OnEvent'
[string "*:OnEvent"]:1: in function <[string "*:OnEvent"]:1>
Locals: self = <table> {
Register = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:311
callbacks = <table> {
}
Unlock = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:333
Lock = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:321
ShowOnEnter = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:409
SetButtonToPosition = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:442
SetButtonRadius = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:433
UnregisterAllCallbacks = <function> defined @Interface\AddOns\PoisonCharges\Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua:174
notCreated = <table> {
}
radius = 5
GetMinimapButton = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:384
IsRegistered = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:359
tooltip = LibDBIconTooltip {
}
RegisterCallback = <function> defined @Interface\AddOns\PoisonCharges\Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua:90
Show = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:350
GetButtonList = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:425
UnregisterCallback = <function> defined @Interface\AddOns\PoisonCharges\Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua:153
Refresh = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:363
objects = <table> {
}
callbackRegistered = true
Hide = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:345
IconCallback = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:25
}
name = "PoisonCharges"
object = <table> {
}
db = 359.542840
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to index local 'db' (a number value)"
lib = <table> {
Register = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:311
callbacks = <table> {
}
Unlock = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:333
Lock = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:321
ShowOnEnter = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:409
SetButtonToPosition = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:442
SetButtonRadius = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:433
UnregisterAllCallbacks = <function> defined @Interface\AddOns\PoisonCharges\Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua:174
notCreated = <table> {
}
radius = 5
GetMinimapButton = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:384
IsRegistered = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:359
tooltip = LibDBIconTooltip {
}
RegisterCallback = <function> defined @Interface\AddOns\PoisonCharges\Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua:90
Show = <function> defined @Interface\AddOns\PoisonCharges\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua:350
GetButtonList = <fun
Thus I'm asking for help: how to make a working movable minimap button for your addon?
|