GitXplorerGitXplorer
M

LibCooldownTracker-1.0-3.3.5

public
0 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
f284ef301c2447d6702ee77deae93f12e746f6be

Update release.yml

MManneN1 committed 2 months ago
Verified
503634f328cf0b9b26b395c83740110100d0593e

Update README.md

MManneN1 committed 2 months ago
Verified
c45f7a633a0c73c003a4580d41e48f374154b0cd

Update README.md

MManneN1 committed 2 months ago
Verified
8d10ea687446890150000843349a38537af7dc5e

Update README.md

MManneN1 committed 2 months ago
Verified
2c19a737bd334983dec6853bcf8a0acd3aca0bd9

Update README.md

MManneN1 committed 2 months ago
Verified
7d360e4584c01cea86bbbadd0da3e2527c4b72af

Create README.md

MManneN1 committed 2 months ago

README

The README file for this repository.

Information

LibCooldownTracker-1.0 for WoW 3.3.5.

Based on LibCooldownTracker-1.0, thanks Vendethiel and team for the source.

Primary changes:

  • Utilizes GUIDs instead of unitIDs such that it can be utilized by many more AddOns
  • Maintains backwards compatibility (old events still exist)
  • Supports RCE-TBC
  • Built-in spec detection via LibSpecDetection-1.0 (instead of GladiusEx)

Usage

Callbacks:
    LCT_CooldownUsed(unitid, spellid, isEnemy)
    LCT_CooldownUsedByGUID(guid, spellid, isEnemy)
    LCT_CooldownsReset(unitid)
    LCT_CooldownsResetByGUID(guid)

Functions:
    success = lib:Subscribe(self, event, [prefix])
    success = lib:Unsubscribe(self, event, [prefix])
    tpu = lib:GetUnitCooldownInfo(unitid, spellid, [prefix])
    tpu = lib:GetCooldownInfoByGUID(guid, spellid, [prefix])
    lib:AddCustomSpell(spellid, info, prefix)
    spellid, spell_data in lib:IterateCooldowns(class, specID, race, [prefix])
    spell_data = lib:GetCooldownData(spellid, [prefix])
    spells_data = lib:GetCooldownsData()

Examples

-- Example 1: Registering a callback and retrieving cooldown data

local function OnCooldownUsed(event, guid, spellid, isEnemy)
    print("Cooldown used: Event =", event, "GUID =", guid, "Spell ID =", spellid, "Is Enemy =", isEnemy)

    -- Get the cooldown data for the spell
    local spell_data = lib:GetCooldownData(spellid, "myAddOnPrefix")
    if spell_data then
        print("Spell cooldown:", spell_data.cooldown)
        print("Class:", spell_data.class)
    end

    -- Get the current cooldown state for the unit
    local currentData = lib:GetCooldownInfoByGUID(guid, spellid, "myAddOnPrefix")
    if currentData then
        print("Current cooldown start:", currentData.cooldown_start)
        print("Current cooldown end:", currentData.cooldown_end)
    end
end

-- Register the callback
local success = lib:Subscribe(self, "LCT_CooldownUsedByGUID", OnCooldownUsed, "myAddOnPrefix")
if success then
    print("Callback registered successfully for myAddOnPrefix")
end
-- Example 2: Iterating over all cooldowns for a specific class and prefix

for spellid, spell_data in lib:IterateCooldowns("MAGE", nil, nil, "myAddOnPrefix") do
    print("Spell ID:", spellid)
    print("Spell cooldown:", spell_data.cooldown)
    print("Class:", spell_data.class)
    if spell_data.specID then
        print("Spec IDs:", table.concat(spell_data.specID, ", "))
    end
end
-- Example 3: Create a custom spell and update an existing spell definition

 -- Define a new custom spell
local customSpellID = 999999  -- A unique spell ID for the custom spell
local customSpellData = {
    cooldown = 120,                         -- Cooldown duration in seconds
    class = "SHAMAN",                       -- Class associated with the spell
    cooldown_overload = { [262] = 60, },    -- Lower cooldown for Elemental
    sets_cooldowns = {                      -- Spells affected by this cooldown
        { spellid = 51505, cooldown = 10 }, -- Lava Burst, 10-second cooldown
        { spellid = 32182, cooldown = 300 } -- Heroism, 5-minute cooldown
    },
}
   
-- Add the custom spell to the library under a specific prefix
lib:AddCustomSpell(customSpellID, customSpellData, "myAddOnPrefix")
print("Custom spell added successfully:", GetSpellInfo(customSpellID))
    
-- Update an existing spell definition
local existingSpellID = 51505  -- Spell ID for Lava Burst
local updatedSpellData = {
    cooldown = 6,                -- Adjusted cooldown duration
    class = "SHAMAN",            -- Class remains the same
    specID = { 262, 263 },       -- Optional: spell only exists for Elemental and Enhancement
    sets_cooldowns = {           -- Update linked cooldowns
        { spellid = 999999, cooldown = 120 }, -- Custom Spell, 2-minute cooldown
    },
}

-- Assuming the existingSpellID already exists
-- an updated variant connected to the addon prefix "myAddonPrefix" will be created
lib:AddCustomSpell(existingSpellID, updatedSpellData, "myAddOnPrefix")

Prefixes:

Prefixes are used to differentiate addons from one another, such that events for custom defined / updated spellIDs can be sent only to the correct subscriber(s) (callback).

You only have to use prefixes if you want to support adding custom spells / configurations in your AddOn.

If you havn't defined a custom variation of a spell which already exists in the base configuration of the library, you will get the data for the base (non-custom) version of that spell.

The library will maintain extra data for each custom variation of spells defined by users of the library. Don't subscribe with a prefix unless you actually need to, it will only consume more CPU/memory for the client.