From 1530b39e622b8750a2caa06ccfd7b36048a24263 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Thu, 13 Dec 2012 03:52:02 +0000 Subject: [PATCH] Add a "wait" statement to interrupt evaluation of a group. The syntax is "wait " that returns the given node. If part of a group node, then it causes the group to evaluate to the best node of the group up to and including the wait statement. A "wait" node has the same priority as its child node. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@661 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleBestAction.lua | 17 +++++++++++++++++ OvaleCompile.lua | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua index 705001b..998c377 100644 --- a/OvaleBestAction.lua +++ b/OvaleBestAction.lua @@ -456,6 +456,17 @@ function OvaleBestAction:Compute(element) if Ovale.trace then Ovale:Print(element.type.." return "..tostring(startB)..","..tostring(endB)) end return startB, endB, prioriteB, elementB + elseif element.type == "wait" then + if (Ovale.trace) then + Ovale:Print(element.type.." ["..element.nodeId.."]") + end + local startA, endA, prioriteA, elementA = self:Compute(element.a) + -- Special priority value as signal for group Compute(). + if prioriteA then + prioriteA = -1 * prioriteA + end + if Ovale.trace then Ovale:Print(element.type.." return "..tostring(startA)..","..tostring(endA).." ["..element.nodeId.."]") end + return startA, endA, prioriteA, elementA elseif element.type == "not" then local startA, endA = self:ComputeBool(element.a) if startA then @@ -670,6 +681,10 @@ function OvaleBestAction:Compute(element) for k, v in ipairs(element.nodes) do local newStart, newEnd, priorite, nouveauElement = self:Compute(v) + local wait = priorite and priorite < 0 + if wait then + priorite = -1 * priorite + end if newStart~=nil and newStart