ItemBonusLib-1.0/Extended API

From WowAce Wiki
Jump to: navigation, search

ItemBonusLib extended API

ItemBonusLib introduce a extended API that was not present in the original BonusScanner library.

The purpose of the extended API is to help addon author that wants to get bonus information for item sets that are not currently equipped.


Get a table corresponding to the equipment of the given unit. Always works for "player", but needs to be able to inspect for "target" or any other unit.


string - A valid unit name


table - A table containing the equipment of the given unit. Table contains Itemlinks indexed by slot names.


local eq = ibl:GetUnitEquipment("mouseover")


Builds a detail bonus list of all the given equipment.


An equipment table, that contains Itemlinks. Note that indexes may be slot names, but do not need to.


details - A table containing the bonus breakout of the given equipment. The table is indexed by bonus and then by the indexes of <eq>. There is a special "Set" index that is used for bonuses that come from having multiple pieces of a set.


local details = ibl:BuildBonusSet(eq)
print("Stamina of Head slot : ", details.STA and details.STA.Head or 0)


Merge details from a details table into a single bonus table.


table - A details table, as returned by BuildBonusSet().


bonuses - A table containing the merged bonus value.


local bonus = ibl:BuildBonusSet(details)
print("Stamina bonus : ", bonus.STA or 0)

Implementation of ScanEquipment

Given the extended API, the ScanEquipment function is rewritten like this :

function ItemBonusLib:ScanEquipment()
	local eq = self:GetUnitEquipment("player")
	details = self:BuildBonusSet(eq)
	bonuses = self:MergeDetails(details)