Button bar during 'interact with target'?

67 Gnome Priest
0
Is it possible for me to have a button bar appear and disappear if I'm in an 'interact with target' state?

I've created a button bar that lets me run macros to move groups of items between my character and my bank slots. I'd like that button bar to only be visible and active when I'm actually interacting with a banker. Can I do this? How?

The two button bar addons I've tried can show or hide based on macro conditions. The examples are '[combat]'. But if there is a condition for interacting with bankers, I don't "get it" yet.

Thanks in advance for any advice you can give me.
Reply Quote
87 Human Death Knight
14975
Hmmm. The bag addons that I've tried all have the ability to open your inventory when you talk to a banker or vendor or auctioneer, so I would think that would be something hookable, but I don't know any button bars that do it.
Reply Quote
67 Gnome Priest
0
Well, I'm glad I didn't just miss something obvious there. Thanks for confirming.

I was also hoping there might be some other trigger (like the inventory window opening) that could toggle the button bar on or off.
Edited by Nored on 8/10/2012 1:48 PM PDT
Reply Quote
100 Gnome Warrior
14000
I bet Macaroon could do it. It's extremely powerful. Unfortunately it has a huge learning curve. I once started to use it but ditched it because it took less time to just write my own specific-use bar than to figure the addon out.

If the bar will only contain macros, what are the names of the macros? It'd take like 50 lines of code to do a simple bar that appears on BANKFRAME_OPENED and disappears on entering combat or BANKFRAME_CLOSED.
Reply Quote
67 Gnome Priest
0
So far, I have two macros, but was planning on more. "Enchant to bank" and "Enchant from ban"*. The first moves all Dust, Shard, Mote, Crystal, and Elemental items into the bank**. The other moves them from the bank and into my character's bags.

*16 character limit on name hit.
**Thank you badhairday and Dumpster!
Reply Quote
100 Gnome Warrior
14000
This is just thrown together so don't expect bells and whistles. :p

Create the two files named in bold in a folder called BankButtons under AddOns. The next time you run WoW when you open the bank you should see two empty buttons on the bank.

Configurability is 90% of the code for addons like this. Since you don't have a static number of buttons, it includes a primitive drag receive. To populate the buttons with macros, open the bank and /macro to open the macro window. Then drag your macros to their button. (You can't drag a button off, release the mouse and then click the bank button--you need to drag it the whole distance.)

BankButtons.toc
## Interface: 40300
## Title: BankButtons
## Notes: Creates a bar of buttons for use while at the bank
## SavedVariables: BankButtonContents
BankButtons.lua


BankButtons.lua
local NUM_BUTTONS = 2 -- change to number of buttons
local X_OFF = -8-((NUM_BUTTONS-1)/2)*42 -- position relative to BOTTOM of BankFrame
local Y_OFF = 172 -- y position relative to BOTTOM of BankFrame

BankButtonContents = {} -- saved variable, macro names on buttons

local function updateButtons() -- updates all buttons to current macros
for i=1,NUM_BUTTONS do
local button = _G["BankButton"..i]
local macroName = BankButtonContents[i]
button:SetAttribute("type","macro")
button:SetAttribute("macro",macroName)
button.icon:SetTexture((select(2,GetMacroInfo(macroName))))
_G[button:GetName().."Name"]:SetText(macroName)
end
end

local function createButton(id,x,y) -- create BankButton(id) at x,y from X/Y_OFFSET
local button = CreateFrame("Button","BankButton"..id,BankFrame,"ActionButtonTemplate,SecureActionButtonTemplate")
button:SetSize(36,36)
button:SetPoint("TOPLEFT",BankFrame,"BOTTOM",X_OFF+x,Y_OFF+y)
button:SetID(id)
button:SetScript("OnReceiveDrag",function(self)
local cursorType,cursorInfo = GetCursorInfo()
if cursorType=="macro" then
BankButtonContents[self:GetID()] = GetMacroInfo(cursorInfo)
updateButtons() -- update, new macro dragged to a button
ClearCursor()
end
end)
end

local f=CreateFrame("Frame","BankButtons",BankFrame)
f:SetScript("OnEvent",function()
for i=1,NUM_BUTTONS do
createButton(i,(i-1)*42,0)
end
updateButtons() -- update for first login
end)
f:RegisterEvent("PLAYER_LOGIN")


Note the first line of BankButtons.lua:
[code]local NUM_BUTTONS = 2 -- change to number of buttons

Change the 2 to however many buttons you want at the bank.
Reply Quote
67 Gnome Priest
0
That is so cool. Thank you! Thank you! Thank you!

I think I understood most of it. In this line:

local button = CreateFrame("Button","BankButton"..id,BankFrame,"ActionButtonTemplate,SecureActionButtonTemplate")

am I correct in understanding that BankFrame is something that comes from ActionButtonTemplate or SecureActionButtonTemplate?

You might make me into a full fledged Addon programmer yet. ;-)
Reply Quote
100 Gnome Warrior
14000
BankFrame is the actual bank (defined in FrameXML/BankFrame.xml). Instead of watching for the bank opening and closing, the buttons just attach themselves to the bank and make it their parent, so they show/hide alongside the bank also.

If you flesh the addon out at all feel free to post it as your own. Everything I post on this forum I release to the wild for anyone to do with as they please. Good luck with it!
Reply Quote
67 Gnome Priest
0
Thank you very much Ro.
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Reason
Explain (256 characters max)

Reported!

[Close]