Now these forums don't seem too active, but i hope i get some helpful responses.
Now i searched it up a bit, but all of the guides, libraries, general info about this was heavily outdated and old or abandoned.
I just want to add a minimap button for my addon. Now i understand the basics of this, i know the requirements for the specific frame dimensions and how to make it, im just wondering on how getting it to clamp to the minimap. I read something about Get the cursor position relative to the minmap but im still a new addon writer and i am not the most knowledged person.
I just want to know how to make a simple minimap button that clamps to the minimap border.
The easiest method is to use the LDB and LDBIcon libraries so that your minimap button can also plug into any LDB display instead of the minimap (I can tell you most users do not like seeing 20 buttons on their minimap from 20 addons).
local LDB = LibStub("LibDataBroker-1.1", true)
local LDBIcon = LDB and LibStub("LibDBIcon-1.0", true)
if LDB then
local OmenLauncher = LDB:NewDataObject("Omen", {
type = "launcher",
icon = "Interface\\AddOns\\Omen\\icon",
OnClick = function(clickedframe, button)
if button == "RightButton" then Omen:ShowConfig() else Omen:Toggle() end
end,
OnTooltipShow = function(tt)
tt:AddLine(self.defaultTitle)
tt:AddLine("|cffffff00" .. L["Click|r to toggle the Omen window"])
tt:AddLine("|cffffff00" .. L["Right-click|r to open the options menu"])
end,
})
if LDBIcon then
LDBIcon:Register("Omen", OmenLauncher, db.MinimapIcon)
end
end
Here, db.MinimapIcon is your savedvariable data on whether the minimap icon is initially shown or hidden.
Well i looked it up, and i get what your saying im just having a few short term problems.
Where exactly do i download these libraries? I cannot find anywhere to do so, or is this worked differently? Do the addons that support LDB have some built in support? Im pretty sure i understand what your saying, but with all this info on the Data Broker things i cant seem to make out exactly "how" to go about this.
It seems this would be very useful, i just cant understand how this works exactly, as its supposed to be a sorta one for all type of thing? ( well in its very base atleast it seems to me, of course its more complex than that. )
Edit: Its getting late and i gtg, but im gonna check back here tommorrow, so any help is still appreciated for me to read later.
I ( think?) found the LDB forums but it still all confuses me. Curse.com also still confuses me, it seems the Data Broker forums are in a seperate section not acessable from the main forum index? I dunno, my mind might just be to hazy from a long period of no sleep so it might make sense to me later.
Thanks for all the help so far, iv'e done what i think ive should of done so far, but i get an error upon logging in
Using the example the basic first code template off of GitHub i made a new data object and then i registered the icon or w/e LDBIcon tells you to do, and it seems like its atleast running correctly, but then i get an error when it tries to Register the DataObject
The error is
Libs\LibDBIcon-1.0.lua:206: attempt to index local 'object' (a nil value)
Boks-Easy-Warr-1.5.5\Boks_Easy_Warr.lua:933: in main chunk
i tried to look it over, and i tried to see the problem but none of my solutions worked
(Also all this time ive forgotten to update my tocs version number in my addon, just a little note to myself)
Ok, if i can just recieve one last bit of help for this ill be fine
So i understand atleast decently well but im still having two problems.
My icon shows in any LDB Display addon, but i still cannot get LDBIcon to work, is it implemented the same way as any other library? It has its own toc (although i didnt put that in ) but i cannot get it to work. I mean right now it seems like my icon will work with any LDB Display addon but i'd still like to try and get a minimap icon, and the documentation for LDBIcon seems scarce from my searchings.
Also im having trouble getting the tooltip to be shown upon mousing over it. I've tried the several methods it lists but in none of the Display addons ive tried will it work.
Once again thanks for all the help and any future help.
Once you have your LDB data object set up (as it sounds you do) all you need to to get LDBIcon to work is this:
[FONT="Courier New"]LibStub("LibDBIcon-1.0"):Register("My Data Object", myDataObject, settings)[/FONT]
...where [FONT="Courier New"]myDataObject[/FONT] is a reference to your LDB data object, and [FONT="Courier New"]settings[/FONT] is a table (probably in your addon's settings, so self.db.profile.ldbiconsettings or something) where LDBIcon will save information about the icon (show/hide and position).
1. LibDBIcon-1.0\LibDBIcon-1.0.lua:206: attempt to index local 'object' (a nil value)
Boks_Easy_Warr-2.7.0\Boks_Easy_Warr.lua:935: in main chunk
also i was using buttonbin to test my object, and it was working fine, but then once when i did a console reloadui it broke for some reason. this is the error
2. ButtonBin-1.0.60\ButtonBin.lua:461: attempt to index local 'tt' (a function value)
ButtonBin-1.0.60\ButtonBin.lua:1749: in function `UpdateBlock'
ButtonBin-1.0.60\ButtonBin.lua:494: in function `EnableDataObject'
ButtonBin-1.0.60\ButtonBin.lua:338: in function `LibDataBroker_DataObjectCreated'
ButtonBin-1.0.60\ButtonBin.lua:632: in function `ApplyProfile'
ButtonBin-1.0.60\ButtonBin.lua:520: in function <Interface\AddOns\ButtonBin\ButtonBin.lua:510>
(tail call): ?:
<in C code>: ?
<string>:"safecall Dispatcher[1]":9: in function <[string "safecall Dispatcher[1]"]:5>
(tail call): ?:
AceAddon-3.0\AceAddon-3.0.lua:366: in function `EnableAddon'
AceAddon-3.0\AceAddon-3.0.lua:436: in function <...\AddOns\ButtonBin\Libs\AceAddon-3.0\AceAddon-3.0.lua:422>
<in C code>: in function `LoadAddOn'
Interface\FrameXML\UIParent.lua:229: in function `UIParentLoadAddOn':
Interface\FrameXML\UIParent.lua:252: in function `CombatLog_LoadUI':
Interface\FrameXML\UIParent.lua:414: in function `UIParent_OnEvent':
<string>:"*:OnEvent":1: in function <[string "*:OnEvent"]:1>
im not sure what caused that, as deleting everything that could effect it in my code doesnt work
Unless you have another line of code setting the value of the variable [FONT="Courier New"]BoksEasyWarr[/FONT], that is your problem. The second argument to LDBIcon:Register must be the data object itself, not just the data object's title. Try this (take note of the bolded sections):
Thanks for all the help, and sorry for my extreme noobiness with this code, that was perfectly and was simple enough that i should have noticed it myself.
Everything shows up now, my only problem is making the tooltip show up. using the above code ( but with the first line of the tooltip code replacing self.defaultTitle with "Boks Easy Warr" ) it will never show up. It says different display addons might take different ways, but testing it on multiple display addons still won't show a tooltip on any of them.
Edit: Also i've marked the table with which the Icon uses as its saved table to be saved in my toc, and atleast part of it does seem to be saving it does not seem to be loading up and using those saved variables or altering them now.
AKA at first it saved minimapPos and radius as values, but now even if i move the icon, hide it, move the minimap itself, etc none of those two set values ever change, or a new value is never added (like it says it should save wether its hidden or not, and yet it does not do that.) So those initial values which it saved the first time arent changing and arent even being used, it just puts the minimap icon in a different spot everytime.
I hid it using the LibStub("LibDBIcon-1.0"):Hide("BoksEasyWarr") which worked but it doesnt save that.
Well with a tiny bit of descronstructing from another addon i managed to get the tooltips working, but my minimap icon still randomly generates its position upon loggin.
I have looked at this and tried to change it as much as possible to get it to work, i don't wanna keep posting here because i wanted to try and solve it myself but i'm thoroughly stumped. I dunno if my eyes are fooling me and the name is misspelled somewhere but ive checked over it to the extent of my knowledge with assistance from the web. The table does not seem to be saving or loading up properly. It saved the table once and now won't save it so the addon keeps randomizing the minimap button position upon log in. All the code that can affect the data object in anyway can be found here
The third parameter to LDBIcon:Register must be a table to contain position and other settings for the minimap icon. Do not put your whole saved variables table in there. If "BEWdb" contains anything other than settings from LDBIcon, you're doing it wrong, and you should add a "minimapIcon" table within the "BEWdb" table, and give LDBIcon that subtable:
You may also want to initialize your saved variables properly, by creating a frame, registering for the ADDON_LOADED event, and when the addon loaded is yours, initialize your saved variables and unregister the event.
No, that is wrong. For some reason the OnTooltipShow function was designed without the self parameter. It caused me a great deal of headaches in my own plugins, trying to figure out why I was getting nil value errors for the tooltip parameter. OnTooltipShow = function(tooltip) is correct.
Well i found out how to make the tooltip appear by looking into another addons code but im still having the problem. I believe im initializing my tables properly, how should i be? Ive had no problem with my normal settings table so far. And yes BEWdb was a brand new table i created that stores no other options.
However i do believe i've seen a flaw. Moving the minimap icon does not appear to be changing the value in the table, so the value to save upon log out is the same as when it was logged in.
So when i load the addon for the very first time it checks to see if BEWdb.minimapIcon has any values associated with it, if not it assigns the Libs default values.
If i move the icon, hide it, etc it will not alter the table at all, causing the values on log out to be the same as when i logged in.
When it next loads it sees that the table does have values from the last login so it doesnt change those, but wont even use the assigned values that it generated last time, it still just randomizes it.
Hope that made sense. Im guessing the lib is suppose to alter the variables itself upon log out, but it's not effect the variables at all besides it preliminary launch when it generates its defaults.
It should indeed be updating those values, and is working fine for the addons I have that use LDBIcon (at least for hiding the buttons, since I never want crap around my minimap).
I noticed that you changed the name of your SV table from "BokSettings" to "BEWdb" in your code... did you also change it in your TOC?
Now i searched it up a bit, but all of the guides, libraries, general info about this was heavily outdated and old or abandoned.
I just want to add a minimap button for my addon. Now i understand the basics of this, i know the requirements for the specific frame dimensions and how to make it, im just wondering on how getting it to clamp to the minimap. I read something about Get the cursor position relative to the minmap but im still a new addon writer and i am not the most knowledged person.
I just want to know how to make a simple minimap button that clamps to the minimap border.
Any help is appreciated.
Here, db.MinimapIcon is your savedvariable data on whether the minimap icon is initially shown or hidden.
Where exactly do i download these libraries? I cannot find anywhere to do so, or is this worked differently? Do the addons that support LDB have some built in support? Im pretty sure i understand what your saying, but with all this info on the Data Broker things i cant seem to make out exactly "how" to go about this.
It seems this would be very useful, i just cant understand how this works exactly, as its supposed to be a sorta one for all type of thing? ( well in its very base atleast it seems to me, of course its more complex than that. )
Edit: Its getting late and i gtg, but im gonna check back here tommorrow, so any help is still appreciated for me to read later.
I ( think?) found the LDB forums but it still all confuses me. Curse.com also still confuses me, it seems the Data Broker forums are in a seperate section not acessable from the main forum index? I dunno, my mind might just be to hazy from a long period of no sleep so it might make sense to me later.
forums.wowace.com
Using the example the basic first code template off of GitHub i made a new data object and then i registered the icon or w/e LDBIcon tells you to do, and it seems like its atleast running correctly, but then i get an error when it tries to Register the DataObject
The error is
Libs\LibDBIcon-1.0.lua:206: attempt to index local 'object' (a nil value)
Boks-Easy-Warr-1.5.5\Boks_Easy_Warr.lua:933: in main chunk
i tried to look it over, and i tried to see the problem but none of my solutions worked
(Also all this time ive forgotten to update my tocs version number in my addon, just a little note to myself)
So i understand atleast decently well but im still having two problems.
My icon shows in any LDB Display addon, but i still cannot get LDBIcon to work, is it implemented the same way as any other library? It has its own toc (although i didnt put that in ) but i cannot get it to work. I mean right now it seems like my icon will work with any LDB Display addon but i'd still like to try and get a minimap icon, and the documentation for LDBIcon seems scarce from my searchings.
Also im having trouble getting the tooltip to be shown upon mousing over it. I've tried the several methods it lists but in none of the Display addons ive tried will it work.
Once again thanks for all the help and any future help.
Hoping you read this -BokTheGolem
[FONT="Courier New"]LibStub("LibDBIcon-1.0"):Register("My Data Object", myDataObject, settings)[/FONT]
...where [FONT="Courier New"]myDataObject[/FONT] is a reference to your LDB data object, and [FONT="Courier New"]settings[/FONT] is a table (probably in your addon's settings, so self.db.profile.ldbiconsettings or something) where LDBIcon will save information about the icon (show/hide and position).
also i was using buttonbin to test my object, and it was working fine, but then once when i did a console reloadui it broke for some reason. this is the error
im not sure what caused that, as deleting everything that could effect it in my code doesnt work
heres my embeds.xml which i run first in my toc if that could be the problem
and thats all the code pertaining to the LibDB stuff
Edit: And although the error persisted for awhile im no longer able to replicate the buttonbin error.
Everything shows up now, my only problem is making the tooltip show up. using the above code ( but with the first line of the tooltip code replacing self.defaultTitle with "Boks Easy Warr" ) it will never show up. It says different display addons might take different ways, but testing it on multiple display addons still won't show a tooltip on any of them.
Edit: Also i've marked the table with which the Icon uses as its saved table to be saved in my toc, and atleast part of it does seem to be saving it does not seem to be loading up and using those saved variables or altering them now.
AKA at first it saved minimapPos and radius as values, but now even if i move the icon, hide it, move the minimap itself, etc none of those two set values ever change, or a new value is never added (like it says it should save wether its hidden or not, and yet it does not do that.) So those initial values which it saved the first time arent changing and arent even being used, it just puts the minimap icon in a different spot everytime.
I hid it using the LibStub("LibDBIcon-1.0"):Hide("BoksEasyWarr") which worked but it doesnt save that.
You use <Include> on XML files, and <Script> on Lua files. Not the other way around or any other combination.
I have looked at this and tried to change it as much as possible to get it to work, i don't wanna keep posting here because i wanted to try and solve it myself but i'm thoroughly stumped. I dunno if my eyes are fooling me and the name is misspelled somewhere but ive checked over it to the extent of my knowledge with assistance from the web. The table does not seem to be saving or loading up properly. It saved the table once and now won't save it so the addon keeps randomizing the minimap button position upon log in. All the code that can affect the data object in anyway can be found here
http://pastebin.com/d6afd065b
You may also want to initialize your saved variables properly, by creating a frame, registering for the ADDON_LOADED event, and when the addon loaded is yours, initialize your saved variables and unregister the event.
No, that is wrong. For some reason the OnTooltipShow function was designed without the self parameter. It caused me a great deal of headaches in my own plugins, trying to figure out why I was getting nil value errors for the tooltip parameter. OnTooltipShow = function(tooltip) is correct.
However i do believe i've seen a flaw. Moving the minimap icon does not appear to be changing the value in the table, so the value to save upon log out is the same as when it was logged in.
So when i load the addon for the very first time it checks to see if BEWdb.minimapIcon has any values associated with it, if not it assigns the Libs default values.
If i move the icon, hide it, etc it will not alter the table at all, causing the values on log out to be the same as when i logged in.
When it next loads it sees that the table does have values from the last login so it doesnt change those, but wont even use the assigned values that it generated last time, it still just randomizes it.
Hope that made sense. Im guessing the lib is suppose to alter the variables itself upon log out, but it's not effect the variables at all besides it preliminary launch when it generates its defaults.
I noticed that you changed the name of your SV table from "BokSettings" to "BEWdb" in your code... did you also change it in your TOC?