Custom Macro: howto - HgAlexx/Buffet GitHub Wiki

The basics

Start the source code with:

local bests, cache, availables = ...

  • The variable bests will contains the ids of the best items found in your bags at time of macro update.
  • The variable cache will contains the item cache with all the data about them.
  • The variable availables will contains the all the ids of all available items found in your bags at time of macro update, sorted by value from high to low

You can omit cache and/or availables if you don't need them:

local bests = ...

local bests, cache = ...

local bests, _, availables = ...

The bests variable contains the following fields:

int bests.bandage
int bests.rune
int bests.conjuredFood
int bests.conjuredDrink
int bests.food
int bests.drink
int bests.wellFedFood
int bests.wellFedDrink
int bests.healthstone
int bests.manaGem
int bests.healthPotion
int bests.toxicPotion
int bests.manaPotion

The availables variable contains the following:

list<item> availables.bandage
list<item> availables.rune
list<item> availables.conjuredFood
list<item> availables.conjuredDrink
list<item> availables.food
list<item> availables.drink
list<item> availables.wellFedFood
list<item> availables.wellFedDrink
list<item> availables.healthstone
list<item> availables.manaGem
list<item> availables.healthPotion
list<item> availables.toxicPotion
list<item> availables.manaPotion

the type item contains the following fields:

int item.itemId
double item.value -- health or mana value
int item.itemCount -- this is the number of item found in your bags

The code must return the full macro content, example:

return "#showtooltip\n/cast item:" .. (bests.food or 6948)

Accessing cached itemData

If you need to access item data, use the cache variable, be sure to check for nil like this:

local itemData = cache and cache[itemIdYouWant] or nil

if itemData then
-- here you can access all the data about that item:
--    itemData.itemId
--    itemData.isHealth
--    itemData.isMana
--    itemData.isConjured
--    itemData.isWellFed
--    itemData.isPct
--    itemData.isFoodAndDrink
--    itemData.isPotion
--    itemData.isToxicPotion
--    itemData.isBandage
--    itemData.isRestricted
--    itemData.isOverTime
--    itemData.health
--    itemData.mana
--    itemData.overTime
end

Custom macro icon

You can specify the macro icon to use by adding a second parameter to the return statement

return "/cast item:" .. bests.food, "INV_Misc_QuestionMark"

This second parameter is optional and default to "INV_Misc_QuestionMark"

Examples

Check the Custom macros page.

⚠️ **GitHub.com Fallback** ⚠️