From 167e8a84444735444f17acbbf7c08580cf7b2512 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Tue, 12 Mar 2013 04:46:04 +0000 Subject: [PATCH] Fix error in using "more" or "less" with decreasing values. When using a script condition that has a decreasing value, e.g., BuffRemains(), the value is a function f(t) = value + (t - origin) * rate where rate is negative. When using the "more"/"less" comparators, e.g., BuffRemains(more 3), this effectively solves the following inequality: f(t) = value + (t - origin) * rate > 3 When the rate is negative, the inequality is reversed, and you end up with: t < (3 - value)/rate + origin Prior to this commit, Ovale was using the wrong answer of: t > (3 - value)/rate + origin This had broken scripts that were using the verbose method of comparing values. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@751 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleCondition.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OvaleCondition.lua b/OvaleCondition.lua index 1cd43ef..f202d80 100644 --- a/OvaleCondition.lua +++ b/OvaleCondition.lua @@ -286,10 +286,10 @@ local function testValue(comparator, limit, value, atTime, rate) else Ovale:Error("Unknown operator "..comparator) end - elseif comparator == "more" then - return (limit-value)/rate + atTime - elseif comparator == "less" then - return 0, (limit-value)/rate + atTime + elseif (comparator == "more" and rate > 0) or (comparator == "less" and rate < 0) then + return (limit - value) / rate + atTime + elseif (comparator == "more" and rate < 0) or (comparator == "less" and rate > 0) then + return 0, (limit - value) / rate + atTime else Ovale:Error("Unknown operator "..comparator) end -- 1.7.9.5