-
-
Notifications
You must be signed in to change notification settings - Fork 49
Rules API
Bagnon and Bagnonium allow you to create custom rules for filtering items.
Rules are managed through a shared API in BagBrother, registering a rules in one addon is exactly the same as on the other. In the remainder of this page, please consider BagBrother to correspond to either Bagnon and Bagnonium.
To register a rule, besides picking a title and an icon, all you need is to write a function:
BagBrother.Rules:Register {
id = 'MyRule',
title = 'My Rule',
icon = 'SomeIcon.jpg',
filter = function(frame, bag, slot, family, info)
-- your logic goes here
end
}Whenever a rule is selected, its filter function is called once per item slot in that frame, to ask whether it should be shown or hidden. Here are a few examples of simple filter functions:
function(frame, bag, slot, family, info)
return true -- shows all slots
end
function(frame, bag, slot, family, info)
return false -- hides all slots
end
function(frame, bag, slot, family, info)
return bag == 0 -- shows backpack only
end
function(frame, bag, slot, family, info)
return slot == 1 -- shows the first slot of each bag
endAs described, the filter function is called, for each slot, with 5 arguments:
| Argument | Type | Description |
|---|---|---|
| frame | frame | Panel being filtered. Only useful in advanced use cases. |
| bag | number | The ID of the bag being tested. |
| slot | number | Index of the slot inside the bag. |
| family | number | Type of the bag (0x80000 for reagent bags; -0x1 for account tabs). |
| info | table | Information about the item in the slot. |
Rules:Register has three mandatory proprieties:
| Required | Type | Description |
|---|---|---|
| id | string (unique) | A unique identifier for your rule. It should never change. |
| title | string | Name of your rule which will appear in the UI. |
| icon | string/number | AtlasID, FileID or file path to a texture. |
Notice that filter is not mandatory. This is because there are alternate proprieties for implementing the filtering function, which mimic user-made rules. Here is the full list of optional parameters:
| Optional | Type | Description |
|---|---|---|
| filter | function | The filtering function, described above. |
| macro | string | Overwrites filter and implements a macro filter. |
| search | string | Overwrites filter and implements a search filter, using LibItemSearch. |
| static | boolean | If enabled, rule will not be recalculated whenever items change, only when bags do. Used to optimize performance. |
This is the Bagnon and Bagnonium wiki. Wiki Home
For Users
Existing Plugins
Search Syntax
Macro Filters
For Developers
Skins API
Rules API
Custom Events
Sorting Items