From 6575ec3a19d577cfa515fb528a8575df0b232db0 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Mon, 21 Apr 2014 05:02:55 +0000 Subject: [PATCH] Add WildMushroomCount() condition. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1308 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- conditions/WildMushroomCount.lua | 41 ++++++++++++++++++++++++++++++++++++++ conditions/files.xml | 1 + 2 files changed, 42 insertions(+) create mode 100644 conditions/WildMushroomCount.lua diff --git a/conditions/WildMushroomCount.lua b/conditions/WildMushroomCount.lua new file mode 100644 index 0000000..0440026 --- /dev/null +++ b/conditions/WildMushroomCount.lua @@ -0,0 +1,41 @@ +--[[-------------------------------------------------------------------- + Ovale Spell Priority + Copyright (C) 2014 Johnny C. Lam + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License in the LICENSE + file accompanying this program. +--]]-------------------------------------------------------------------- + +local _, Ovale = ... + +do + local OvaleCondition = Ovale.OvaleCondition + + local API_GetTotemInfo = GetTotemInfo + local Compare = OvaleCondition.Compare + + --- Get the number of active Wild Mushrooms by the player. + -- @name WildMushroomCount + -- @paramsig number or boolean + -- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more. + -- @param number Optional. The number to compare against. + -- @return The number of Wild Mushrooms. + -- @return A boolean value for the result of the comparison. + -- @usage + -- if WildMushroomCount() < 3 Spell(wild_mushroom_caster) + + local function WildMushroomCount(condition) + local comparator, limit = condition[1], condition[2] + local count = 0 + for slot = 1, 3 do + local haveTotem = API_GetTotemInfo(slot) + if haveTotem then + count = count + 1 + end + end + return Compare(count, comparator, limit) + end + + OvaleCondition:RegisterCondition("wildmushroomcount", false, WildMushroomCount) +end diff --git a/conditions/files.xml b/conditions/files.xml index 6087ce7..25086c1 100644 --- a/conditions/files.xml +++ b/conditions/files.xml @@ -106,4 +106,5 @@