Macros - Jaliborc/BagBrother GitHub Wiki
If you want to get the maximum control out of the tabs in Bagnon or Bagnonium, creating macro filters is the way to do it. We recommend you start by checking the code of the filters that come pre-installed with the addon. You can do this in-game to see real examples in action.
π§ What Is a Macro Filter?
A macro filter is a short piece of code written in Lua. It is run once for each item slot in your bags. The macro decides whether to show or hide each slot.
All your macro has to do is return
a true or false statement:
true
- show this slotfalse
- hide this slot
Hereβs the simplest possible macro:
return true
This tells the addon to show every item slot β no filtering at all.
Letβs make it more interesting.
π§ͺ Basic Filtering
Suppose you only want to show the first slot of every bag. You can do that with this:
return slot == 1
This will be a true statement only for the first slot of each bag. Everything else will be hidden.
All filters follow this same idea: you write a condition that tells the game whether to show an item slot.
π‘ Simple Examples
Here are a few more examples to get you started:
Macro | Code | Explanation |
---|---|---|
Backpack Only | return bag == 0 |
Only slots in the backpack have a bag ID of 0 . |
1st Warband Tab | return bag == 12 |
Warband tab IDs start at 12 . |
2nd Warband Tab | return bag == 13 |
Warband tab IDs start at 12 . |
Tackleboxes Only | return family == 0x8000 |
Only slots from a tackle-box have a bag type of 0x8000 . |
Only Single Items | return info.stackCount == 1 |
info has a lot of information about the item in the slot, such as its stack size. |
Only Sellable | return not info.hasNoValue |
By checking that an item has a vendor value, we know it can be sold there. |
You can copy and paste these codes ingame to try them out.
π¦ What Information Can I Use?
Each time your macro runs, it receives information about one specific item slot to make a decision on. You can use the following built-in variables in your macro:
Variable | Type | Description |
---|---|---|
frame |
frame | Panel being filtered. Only useful in advanced use cases. |
bag |
number | The Bag ID β identifies which bag the slot is in. |
slot |
number | The slot position inside the bag (starts at 1). |
family |
number | The bag type (e.g. 0x80000 for reagent bags; -0x1 for account tabs). |
info |
table | Details about the item in this slot (see below). |
The info
table contains useful details about the item, including:
info.stackCount
β How many of the item are stacked in the slotinfo.isBound
β Whether the item is soulboundinfo.quality
β The item's rarityinfo.itemID
β The ID of the item
You can learn more about this data here: API_C_Container.GetContainerItemInfo
π Want to Go Further?
If you're feeling confident, you can also use any of the regular WoW functions in your macro, such as:
These let you get even more advanced information about the item, such as if it's soulbound, what its name is, and so on.
But donβt worry about those if it is too much for you. You can do a lot with just the simple values shown above!