ItemBonusLib-1.0/Extended API
From WowAce Wiki
Contents |
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.
:GetUnitEquipment("<unit>")
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.
Args
- "<unit>"
- string - A valid unit name
Returns
table - A table containing the equipment of the given unit. Table contains Itemlinks indexed by slot names.
Example
local eq = ibl:GetUnitEquipment("mouseover")
:BuildBonusSet(<eq>)
Builds a detail bonus list of all the given equipment.
Args
- <eq>
- An equipment table, that contains Itemlinks. Note that indexes may be slot names, but do not need to.
Returns
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.
Example
local details = ibl:BuildBonusSet(eq)
print("Stamina of Head slot : ", details.STA and details.STA.Head or 0)
:MergeDetails(<details>)
Merge details from a details table into a single bonus table.
Args
- <details>
- table - A details table, as returned by BuildBonusSet().
Returns
bonuses - A table containing the merged bonus value.
Example
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)
self:TriggerEvent("ItemBonusLib_Update")
end

