LibCooldown-Item-2.0
From WowAce Wiki
| Summary | |
|---|---|
| Lib: Cooldown-Item-2.0 | |
| Register item cooldowns to more descriptive events. | |
| TOC | 2.4 (20400) |
| Category | Libraries |
| Author | Sirow |
| Details | |
| Version | 2.0 |
| OptionalDeps | LibStub, CallbackHandler-1.0, LibSimpleTimer-1.0, LibBabble-Zone-3.0 |
| Links | |
| Betas | Ace SVN Zip |
| Changelog | FishEye |
LibCooldown-Item-2.0 - API Documentation
Callbacks Fired
:LibCooldownInventoryItem_Start(itemID, itemName, startTime, duration, bagID, slotID)
Arguments
- itemID
- number - ItemID of triggered item
- itemName
- string - Name of triggered item
- startTime
- number - Time when cooldown started (as returned by GetTime())
- duration
- number - Duration of cooldown until finished
- bagID
- number - Bag ID as used by GetContainerItemCooldown(bagID, slotID)
- slotID
- number - Bag slot ID as used by GetContainerItemCooldown(bagID, slotID)
Notes
- Fired whenever a cooldown of a (not equipped) item starts
:LibCooldownEquippedItem_Start(itemID, itemName, startTime, duration, slotID)
Arguments
- itemID
- number - ItemID of triggered item
- itemName
- string - Name of triggered item
- startTime
- number - Time when cooldown started (as returned by GetTime())
- duration
- number - Duration of cooldown until finished
- slotID
- number - Equipment slot as used by GetInventoryItemCooldown("player", slotID)
Notes
- Fired whenever a cooldown of an (equipped) item starts
:LibCooldownInventoryItem_End(itemID, itemName, startTime, duration, bagID, slotID)
Arguments
- itemID
- number - ItemID of triggered item
- itemName
- string - Name of triggered item
- startTime
- number - Time when cooldown started (as returned by GetTime())
- duration
- number - Duration of cooldown until finished
- bagID
- number - Bag ID as used by GetContainerItemCooldown(bagID, slotID)
- slotID
- number - Bag slot ID as used by GetContainerItemCooldown(bagID, slotID)
Notes
- Fired whenever a cooldown of an (not equipped) item ends
:LibCooldownEquippedItem_End(itemID, itemName, startTime, duration, slotID)
Arguments
- itemID
- number - ItemID of triggered item
- itemName
- string - Name of triggered item
- startTime
- number - Time when cooldown started (as returned by GetTime())
- duration
- number - Duration of cooldown until finished
- slotID
- number - Equipment slot as used by GetInventoryItemCooldown("player", slotID)
Notes
- Fired whenever a cooldown of an (equipped) item ends
CallbackHandler-1.0 API
:RegisterEvent()
myAddon:RegisterEvent("eventName"[, method[, arg]])
library.RegisterEvent(myTable, "eventName"[, method[, arg]])
library.RegisterEvent("myAddonId", "eventName"[, method[, arg]])
- "eventName"
- (string) - the name of the event you want to listen to
- method
- (string or function) - which method to call. If string, self["method"] will be called. If left out (nil), self["eventName"] will be called.
- arg
- (optional) - If present (even nil), this value will be passed to the receiving function.
Registrations are always associated with the supplied self. This means that you'll want to embed the library, or do the call like .RegisterEvent(myTable, ...). Note the use of " . " (period) rather than " : " (colon).
If you do not have a sane self table to associate your registrations with, you can substitute it for a string. Note the use of "." rather than ":".
-
library.RegisterEvent("myAddonId", "eventName", ...)
This string variant of a self will not be passed to the receiving function.
Callback arguments
If the method is a plain function, it will be called as:
-
method("eventName", (arguments to the event)) - or, with an arg specified when registering:
-
method(arg, "eventName", (arguments to the event))
If the method is a string (method name), it will be called as:
-
self["method"](self, "eventName", (arguments to the event)) - or, with an arg specified when registering:
-
self["method"](self, arg, "eventName", (arguments to the event))
:UnregisterEvent()
myAddon:UnregisterEvent("eventName")
library.UnregisterEvent(myTable, "eventName")
library.UnregisterEvent("myAddonId", "eventName")
- "eventName"
- the name of the event that you no longer wish to receive.
Note that the supplied self must match the self supplied to :RegisterEvent(), or nothing will be unregistered.
:UnregisterAllEvents()
:UnregisterAllEvents()
library.UnregisterAllEvents("myAddonId", myTable, ...)
UnregisterAllEvents will unregister all events associated with the given self, as well as with additional arguments given.

