From 1778a0a4b8386536bdac9c3c7b4efd1b7286889b Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Wed, 10 Mar 2010 17:50:02 -0600 Subject: [PATCH] Fixed regexes in damageRange and validateNumber --- Regexps.lua | 4 ++-- weights.lua | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Regexps.lua b/Regexps.lua index 34f9a00..c65bb34 100644 --- a/Regexps.lua +++ b/Regexps.lua @@ -178,7 +178,7 @@ end function WeightsWatcher:damageRange(textL, textR) local speed local stats = setmetatable({}, ww_normalStatsMetatable) - local start, _, added, minVal, maxVal, name = string.find(textL, "^(%+?)(%d+) %- (%d+) (%a* ?Damage)") + local start, _, added, minVal, maxVal, name = string.find(textL, "^(%+?)(%d+) %- (%d+) (%a* ?Damage)$") if start then if added == "+" then added = "Added " @@ -187,7 +187,7 @@ function WeightsWatcher:damageRange(textL, textR) stats["Maximum " .. added .. name] = tonumber(maxVal) end if textR then - start, _, speed = string.find(textR, "^Speed (%d[%d.]+)$") + start, _, speed = string.find(textR, "^Speed (%d+%.?%d*)$") if start then stats["Speed"] = tonumber(speed) end diff --git a/weights.lua b/weights.lua index 47200f7..025554a 100644 --- a/weights.lua +++ b/weights.lua @@ -72,16 +72,16 @@ function initializeWeightsConfig() end function validateNumber(newChar, newText) - if string.find(newChar, "^[0-9]$") then + if string.find(newChar, "^%d$") then return true elseif newChar == '.' then - local first = newText:find(".", 1, true) - local second = newText:find(".", first + 1, true) + local first = newText:find("%.", 1, true) + local second = newText:find("%.", first + 1, true) if not second then return true end elseif newChar == '-' then - if not string.find(newText, "-", 2) then + if not string.find(newText, "%-", 2) then return true end end -- 1.7.9.5