Download
(3 Kb)
Download
Updated: 05/04/22 10:17 AM
Compatibility:
Ascending Tide (7.3.5)
Updated:05/04/22 10:17 AM
Created:04/04/22 07:42 PM
Monthly downloads:1,503
Total downloads:42,122
Favorites:8
MD5:
LibSetDetection  Popular! (More than 5000 hits)
Version: 3
by: ExoY [More]
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:
  1. LibSetDetection.RegisterForSetChanges(name, callback)

if callbacks are desired for any sets or


Lua Code:
  1. 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:
  1. local function MyCallback(setId, status)
  2.    if status then
  3.       -- set with *setId* is now complete
  4.    else
  5.       -- set with *setId* is now incomplete
  6.    end
  7. end
  8. 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:
  1. LibSetDetection.RegisterForCustomSlotUpdateEvent(name, callback)
  2.  
  3. 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:
  1. LibSetDetection.GetCompleteSetsList()
Lua Code:
  1. {
  2. [*completeSetId1*] = *setName*,
  3. [*completeSetId2*] = *setName*,
  4. }

EquipSlotList
provides a list of the slot ids and categorizes them into body, front and backbar.
Lua Code:
  1. LibSetDetection.GetEquipSlotList()
Lua Code:
  1. {
  2.   ["body"] = {
  3.     [EQUIP_SLOT_HEAD] = "head",                   --  0
  4.     [EQUIP_SLOT_NECK] = "necklace",               --  1
  5.     [EQUIP_SLOT_CHEST] = "chest",                 --  2
  6.     [EQUIP_SLOT_SHOULDERS] = "shoulders",         --  3
  7.     [EQUIP_SLOT_WAIST] = "waist",                 --  6
  8.     [EQUIP_SLOT_LEGS] = "legs",                   --  8
  9.     [EQUIP_SLOT_FEET] = "feet",                   --  9
  10.     [EQUIP_SLOT_RING1] = "ring1",                 -- 11
  11.     [EQUIP_SLOT_RING2] = "ring2",                 -- 12
  12.     [EQUIP_SLOT_HAND] = "hand",                   -- 16
  13.   },
  14.   ["front"] = {
  15.     [EQUIP_SLOT_MAIN_HAND] = "mainFront",         --  4
  16.     [EQUIP_SLOT_OFF_HAND] = "offFront",           --  5
  17.   },
  18.   ["back"] = {
  19.     [EQUIP_SLOT_BACKUP_MAIN] = "mainBack",        -- 20
  20.     [EQUIP_SLOT_BACKUP_OFF] = "offBack",          -- 21
  21.   }
  22. }

SlotIdSetIdMap
provides the current setId for each slotId. The setId = 0 corresponds to no set or no item.
Lua Code:
  1. LibSetDetection.GetSlotIdSetIdMap()
Lua Code:
  1. {
  2. [EQUIP_SLOT_HEAD] = *setId*,
  3. [EQUIP_SLOT_NECK] = *setId*,
  4. ... --for each slotId
  5. }

EquippedSetsTable
provides information for each set, which has at least on piece equipped.
Lua Code:
  1. LibSetDetection.GetEquippedSetsTable()
Lua Code:
  1. {
  2. [*setId1*] = {
  3.      ["setName"] = *setName*,
  4.      ["maxEquipped" = *numOfSetpiecesForFullBonus*,
  5.      ["numEquipped" = {
  6.           ["front"] = *numSetPiecesFrontBar*, --2 is maximum
  7.           ["back"] = *numSetPiecesBackBar*, --2 is maximum
  8.           ["body"] = *numSetPiecesOnBody*, --10 is maximum
  9.      },
  10.      ["activeBar"] = {
  11.           ["front"] = *isActiveOnFrontBar*, -- boolean
  12.           ["back"] = *isActiveOnBackBar*, -- boolean
  13.           ["body"] = *isActiveOnBody*, -- boolean
  14.      },
  15. },
  16. ... --for each setId equipped
  17. }

Lua Code:
  1. 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:
  1. {
  2.     ["front"] = HOTBAR_CATEGORY_PRIMARY, --0
  3.     ["back"] = HOTBAR_CATEGORY_BACKUP, -- 1
  4.     ["body"] = -1,
  5. }


BarActiveSetIdMap
provides a list of active and complete Sets for each bar.
Lua Code:
  1. LibSetDetection.GetBarActiveSetIdMap()


Lua Code:
  1. {
  2.    ["front"] = {
  3.        [*undauntedSetId*] = *setName*,
  4.        [*weaponSetId*] = *setName*,
  5.        [*bodySetId*] = *setName*,
  6.    },
  7.    ["back"] = {
  8.        [*undauntedSetId*] = *setName*,
  9.        [*jewelrySetId*] = *setName*,
  10.        [*bodySetId*] = *setName*,
  11.    },
  12.    ["body"] =
  13.        [*undauntedSetId*] = *setName*,
  14.        [*bodySetId*] = *setName*,
  15.    },
  16.    ["frontSpecific"] = {
  17.        [*weaponSetId*] = *setName*,  
  18.    },
  19.    ["backSpecific"] = {
  20.        [*jewelrySetId*] = *setName*,  
  21.    },
  22. }
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
Version 1 (May 4th 2022)
* performance improvements

Version 2 (April 11th 2022)
* added exposed function: GetNumPiecesForHotbar()
* changed barList from
Lua Code:
  1. {
  2.     ["front"] = true,
  3.     ["back"] = true,
  4.     ["body"] = true,
  5. }
to
Lua Code:
  1. {
  2.     ["front"] = HOTBAR_CATEGORY_PRIMARY,
  3.     ["back"] = HOTBAR_CATEGORY_BACKUP,
  4.     ["body"] = -1,
  5. }

Version 1 (April 5th 2022)
* release of the library
Archived Files (2)
File Name
Version
Size
Uploader
Date
2
3kB
ExoY
04/10/22 05:11 PM
1
3kB
ExoY
04/04/22 07:42 PM


Post A Reply Comment Options
Unread 04/05/22, 01:48 AM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 4912
File comments: 5989
Uploads: 78
Thank you ExoY for that library.
Remembers me about my ideas to add the proc stuff (abilityIds, whatever could happen as proc) to LibSets but I never gotit to work properly. Need to clean that up now as your lib was created, it fits better into this lib imo. Feel free to spy the code and tables from actual LibSets.
But I think we talked about it 1-2 years ago already and it's difficult to build that into a "lib" you said.
Maybe you can make your mind about it one again. Having a proc lib for the sets would be great for all kind of addons.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: