Extend ItemCooldown() condition to take slot name instead of item ID.
Johnny C. Lam [04-12-14 - 16:20]
Extend ItemCooldown() condition to take slot name instead of item ID.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1293 d5049fe3-3747-40f7-a4b5-f36d6801af5f
diff --git a/conditions/ItemCooldown.lua b/conditions/ItemCooldown.lua
index 4782085..e60800a 100644
--- a/conditions/ItemCooldown.lua
+++ b/conditions/ItemCooldown.lua
@@ -11,6 +11,7 @@ local _, Ovale = ...
do
local OvaleCondition = Ovale.OvaleCondition
+ local OvaleEquipement = Ovale.OvaleEquipement
local API_GetItemCooldown = GetItemCooldown
local Compare = OvaleCondition.Compare
@@ -19,20 +20,27 @@ do
--- Get the cooldown time in seconds of an item, e.g., trinket.
-- @name ItemCooldown
-- @paramsig number or boolean
- -- @param id The item ID.
+ -- @param id The item ID or the equipped slot name.
-- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
-- @param number Optional. The number to compare against.
-- @return The number of seconds.
-- @return A boolean value for the result of the comparison.
-- @usage
- -- if not ItemCooldown(ancient_petrified_seed) >0
+ -- if not ItemCooldown(ancient_petrified_seed) > 0
+ -- Spell(berserk_cat)
+ -- if not ItemCooldown(Trinket0Slot) > 0
-- Spell(berserk_cat)
local function ItemCooldown(condition)
local itemId, comparator, limit = condition[1], condition[2], condition[3]
- local start, duration = API_GetItemCooldown(itemId)
- if start > 0 and duration > 0 then
- return TestValue(start, start + duration, duration, start, -1, comparator, limit)
+ if itemId and type(itemId) ~= "number" then
+ itemId = OvaleEquipement:GetEquippedItem(itemId)
+ end
+ if itemId then
+ local start, duration = API_GetItemCooldown(itemId)
+ if start > 0 and duration > 0 then
+ return TestValue(start, start + duration, duration, start, -1, comparator, limit)
+ end
end
return Compare(0, comparator, limit)
end