Button bar during 'interact with target'?

UI and Macro
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.
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.
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.
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.
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!
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.)

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

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]

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")
local cursorType,cursorInfo = GetCursorInfo()
if cursorType=="macro" then
BankButtonContents[self:GetID()] = GetMacroInfo(cursorInfo)
updateButtons() -- update, new macro dragged to a button

local f=CreateFrame("Frame","BankButtons",BankFrame)
for i=1,NUM_BUTTONS do
updateButtons() -- update for first 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.
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. ;-)
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!
Thank you very much Ro.

Join the Conversation

Return to Forum