/Use Macro help

I often carry different types of food in my bag, whether it be mage food or water, or whatever. I would like to only have one keybind and not have to keep switching the item that’s on the bar, especially since i keep my bars hidden.

Is there a macro that will consume whatever item I have depending on the order I list them at without failing when one is empty?

For a simple example: Purified Draenic Water and Conjured Mana Biscuit

Sure, especially since you can’t drink in combat anyway I don’t think.

What you want is a macro that self-modifies to use the item you have that is highest on your priority list.

Are you able to give an example?

I haven’t tested this yet and I may be going at this a bit to baroquely but this should work.

  • You’ll need an empty macro called “D” (nothing else) and you can’t have more than one called this. This will be the “Drink” macro that’s actually the one you want to push.
  • You’ll need to add to the list of ItemIDs in the short table at the beginning of the Lua code. All that’s there now is your two examples.
  • You’ll need to alter the “B” variable name to be the bag number you keep your drinks in. Valid values are 0-4 with 0 being the backpack and the others in order lining on your bag bar.
/stopmacro [combat]
local t,l,E={27860,34062},1,EditMacro for i=1,#t do for s=1,30 do if l and GetContainerItemID(c,s)==t[i] then E("D",_,_,"/use "..(GetItemInfo(t[i]))) l=nil end end end l=(l and E("D",_,_,"/run print('Out of juice')"))

Run THIS macro once to set things up (after you’ve got the checklist above done) and then any time you get an ‘Out of juice’ message in your chat box, run it again. It’ll pull from your prioritized list the item name of the drink you want.

Any more and I’d have to get into macro chaining code which gets into messing with global space and that’s just dodgy for macros.

You’d probably be better with this as a small addon. That wouldn’t be too awful hard to set up as long as you aren’t asking for a UI of any sort (hard-coding the drink list - a full scan of the bags wouldn’t be too hard in looking for it).

This will NOT edit a macro in combat. Nothing will.

1 Like

Or just use
https://www.curseforge.com/wow/addons/buffet

1 Like

That would honestly be my recommendation. I don’t like to tell folks the “how” on things, but that’s a much better idea.

[quote=“Elvenbane-veknilash, post:5, topic:998440”]
Or just use [buffet]

:o never knew that existed

This is from “nightcracker” on wowinterface.
Apparently I cant put links in my posts so I copy paste his explanation…

/stopmacro [combat]
/run local d,c,i,f=33445,43523,“item”,f82Ht or CreateFrame(“Button”,“f82Ht”,nil,“SecureActionButtonTemplate”)f.s=f.SetAttribute;f.s(f,“type”,i)f.s(f,i,“item:”…(GetItemCount(c)>0 and c or IsUsableItem(d)and d or 43236))
/click f82Ht
You can change which item to use by changing the item ID…
178217 <== Azurebloom Tea (second choice)
113509 <== Mana Bun (first choice)
There is third choice for arena (not sure for this use tho)
43236

Its the thread 32027 on wowinterface if you want to check the original post.

Wrap them in code tags :wink: