From 6ade7c502024fd1ad5207b923e1e5cc711080b7a Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Mon, 21 Apr 2014 05:01:53 +0000 Subject: [PATCH] Implement unit.IsDead() script condition. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1299 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- conditions/IsDead.lua | 40 ++++++++++++++++++++++++++++++++++++++++ conditions/files.xml | 1 + 2 files changed, 41 insertions(+) create mode 100644 conditions/IsDead.lua diff --git a/conditions/IsDead.lua b/conditions/IsDead.lua new file mode 100644 index 0000000..f77d6ea --- /dev/null +++ b/conditions/IsDead.lua @@ -0,0 +1,40 @@ +--[[-------------------------------------------------------------------- + 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_UnitIsDead = UnitIsDead + local ParseCondition = OvaleCondition.ParseCondition + local TestBoolean = OvaleCondition.TestBoolean + + --- Test if the target is dead. + -- @name IsDead + -- @paramsig boolean + -- @param yesno Optional. If yes, then return true if the target is dead. If no, then return true if it isn't dead. + -- Default is yes. + -- Valid values: yes, no. + -- @param target Optional. Sets the target to check. The target may also be given as a prefix to the condition. + -- Defaults to target=player. + -- Valid values: player, target, focus, pet. + -- @return A boolean value. + -- @usage + -- if pet.IsDead() Spell(revive_pet) + + local function IsDead(condition) + local yesno = condition[1] + local target = ParseCondition(condition) + local boolean = API_UnitIsDead(target) + return TestBoolean(boolean, yesno) + end + + OvaleCondition:RegisterCondition("isdead", false, IsDead) +end \ No newline at end of file diff --git a/conditions/files.xml b/conditions/files.xml index d73e298..6087ce7 100644 --- a/conditions/files.xml +++ b/conditions/files.xml @@ -46,6 +46,7 @@