LibSetDetection is a library which keeps track of the equipped gear.
It provides callbacks for when the complete state of a set is changed.
This library is a refined and stand-alone version of the method utilized in my ProcSet addon.
Feel free to let me know, when you embed the lib in your addon, so I can inform you in advance if at some point any functionality is changed.
Benefits of LibSetDetection
- sets are detected when the last bonus is available on any weapon bar - no bar swap needed after gear changes
- notification of the currents sets after login/reloadui and armory build changes
- automatic consideration of perfected and non-perfected set combination for any language
- consideration of two-hander weapons which provide two set boni
- easy to use callbacks for completing and uncompleting sets
- access to comprehensive tables for more specific applications
Callbacks for set changes
The callbacks fire when a set changes between completed and uncompleted.
- Completed means all boni are available on eighter front or! backbar.
- Uncompleted referes to not enough set pieces are available to utilize the set's last boni on eighter bar.
A unique name and the desired function to be called upon need to be provided using eigher
Lua Code:
LibSetDetection.RegisterForSetChanges(name, callback)
if callbacks are desired for any sets or
Lua Code:
LibSetDetection.RegisterForSpecificSetChanges(name, setId, callback)
to track only a certain set, indicated by its
setId.
The callback provides the
setId and the
changeStatus, which indicates the new status.
That means:
- changeStatus = true --> changed from uncomplete to complete
- changeStatus = false --> change from complete to uncomplete
An example for clarification:
Lua Code:
local function MyCallback(setId, status)
if status then
-- set with *setId* is now complete
else
-- set with *setId* is now incomplete
end
end
LibSetDetection:RegisterForSetChanges("myUniqueName", MyCallback)
Non-perfected and perfected Gear
The library actually does not distinguish between those to type and just consideres any perfected pieces as non-perfected. This approach has been chosen as it allows for a dynamic solution and does not require regular updates with the addition of new sets which have a perfected and non-perfected version.
This should be valid as both versions can be combined and the corresponding
abilityId of both sets are identically (with all current sets).
As a consequence:
- the setId provided with the previous named callbacks is always the one of the non-perfected, but the callback will also be triggered if the perfected version is equipped
- when utilizing the tracking of a specific set, only one id needs to be registered to receive the callback for both versions (it doesnt matter if the perfected of non-perfected setId is registered)
Multiple Changes
After a set piece is changed, the library will wait for additional changes before anlysing the new set configuration. This ensures that the internal algorith is only executed ones when using addons for automated equipment change such es
AlphaGear, DressingRoom or WizardsWardrobe or manually equipping/unequipping gear in rapid succession. The delay is currently hardcoded to a waiting time of one second.
Advanced Applications
Additional functionality is provided to enable access to the information used within the library, thus allowing for more specific applications which can not be realized with the callbacks described above.
Lua Code:
LibSetDetection.RegisterForCustomSlotUpdateEvent(name, callback)
LibSetDetection.UnregisterForCustomSlotUpdateEvent(name)
This callback can be utilized as an substitute for the
EVENT_INVENTORY_SINGLE_SLOT_UDATE
with the filters:
- REGISTER_FILTER_BAG_ID, BAG_WORN
- REGISTER_FILTER_IS_NEW_ITEM, false
- REGISTER_FILTER_INVENTORY_UPDATE_REASON , INVENTORY_UPDATE_REASON_DEFAULT
It is executed after all tables within the library are updated, as a result after
multiple changes it is only called upon
once! The callback provides a table wich includes a chronological list of all slots that were checked since the last callback. So after a reloadui or armory build change it will contain a list with all slots.
Moreover this callback can also be used as an indicator that all tables and information within the library are updated after an equipment change. Those tables can be accessed through a number of exposed functions, which are dokumented in the following.
Table Documentation
CompleteSetsList
provides a list of all sets currently considered complete.
Lua Code:
LibSetDetection.GetCompleteSetsList()
Lua Code:
{
[*completeSetId1*] = *setName*,
[*completeSetId2*] = *setName*,
}
EquipSlotList
provides a list of the slot ids and categorizes them into body, front and backbar.
Lua Code:
LibSetDetection.GetEquipSlotList()
Lua Code:
{
["body"] = {
[EQUIP_SLOT_HEAD] = "head", -- 0
[EQUIP_SLOT_NECK] = "necklace", -- 1
[EQUIP_SLOT_CHEST] = "chest", -- 2
[EQUIP_SLOT_SHOULDERS] = "shoulders", -- 3
[EQUIP_SLOT_WAIST] = "waist", -- 6
[EQUIP_SLOT_LEGS] = "legs", -- 8
[EQUIP_SLOT_FEET] = "feet", -- 9
[EQUIP_SLOT_RING1] = "ring1", -- 11
[EQUIP_SLOT_RING2] = "ring2", -- 12
[EQUIP_SLOT_HAND] = "hand", -- 16
},
["front"] = {
[EQUIP_SLOT_MAIN_HAND] = "mainFront", -- 4
[EQUIP_SLOT_OFF_HAND] = "offFront", -- 5
},
["back"] = {
[EQUIP_SLOT_BACKUP_MAIN] = "mainBack", -- 20
[EQUIP_SLOT_BACKUP_OFF] = "offBack", -- 21
}
}
SlotIdSetIdMap
provides the current setId for each slotId. The setId = 0 corresponds to no set or no item.
Lua Code:
LibSetDetection.GetSlotIdSetIdMap()
Lua Code:
{
[EQUIP_SLOT_HEAD] = *setId*,
[EQUIP_SLOT_NECK] = *setId*,
... --for each slotId
}
EquippedSetsTable
provides information for each set, which has at least on piece equipped.
Lua Code:
LibSetDetection.GetEquippedSetsTable()
Lua Code:
{
[*setId1*] = {
["setName"] = *setName*,
["maxEquipped" = *numOfSetpiecesForFullBonus*,
["numEquipped" = {
["front"] = *numSetPiecesFrontBar*, --2 is maximum
["back"] = *numSetPiecesBackBar*, --2 is maximum
["body"] = *numSetPiecesOnBody*, --10 is maximum
},
["activeBar"] = {
["front"] = *isActiveOnFrontBar*, -- boolean
["back"] = *isActiveOnBackBar*, -- boolean
["body"] = *isActiveOnBody*, -- boolean
},
},
... --for each setId equipped
}
Lua Code:
LibSetDetection.GetNumSetPiecesForHotbar(setId, hotbar)
provides direct access to the *numEquipped* subtable. The hotbar parameter needs to be -1, 0 or 1 according to the following table:
Lua Code:
{
["front"] = HOTBAR_CATEGORY_PRIMARY, --0
["back"] = HOTBAR_CATEGORY_BACKUP, -- 1
["body"] = -1,
}
BarActiveSetIdMap
provides a list of active
and complete Sets for each bar.
Lua Code:
LibSetDetection.GetBarActiveSetIdMap()
Lua Code:
{
["front"] = {
[*undauntedSetId*] = *setName*,
[*weaponSetId*] = *setName*,
[*bodySetId*] = *setName*,
},
["back"] = {
[*undauntedSetId*] = *setName*,
[*jewelrySetId*] = *setName*,
[*bodySetId*] = *setName*,
},
["body"] =
[*undauntedSetId*] = *setName*,
[*bodySetId*] = *setName*,
},
["frontSpecific"] = {
[*weaponSetId*] = *setName*,
},
["backSpecific"] = {
[*jewelrySetId*] = *setName*,
},
}
The table shown above is an example for
- one complete undaunted set
- one complete 5 boni set on body parts
- one special weapon set on front bar
- one complete 5 set boni on three jewelry and back bar weapons