From 91d666fa734aebb75de19f62436c2624a6dba6cb Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Mon, 21 Dec 2009 08:21:51 -0600 Subject: [PATCH] Fixed some parsing issues --- Regexps.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Regexps.lua b/Regexps.lua index 6b8323b..9c17e5b 100644 --- a/Regexps.lua +++ b/Regexps.lua @@ -6,7 +6,7 @@ Preprocess = { ["|r$"] = "", ["^|c[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]"] = "", ["Improves"] = "Increases", - ["Increases your"] = "Increases", + ["([Ii]ncreases?) your"] = "%1", ["Increases the target's"] = "Increases", ["Unique%-Equipped"] = "Unique", ["^Use: Teaches you how to permanently enchant "] = "Use: Permanently enchant ", @@ -145,18 +145,20 @@ function WeightsWatcher:multipleStats(text) local stat, stringTable local stats = setmetatable({}, ww_normalStatsMetatable) - text = string.gsub(string.gsub(text, ",? and ", "\a"), ", ", "\a") + start, _, value = string.find(text, " and %a[%a ]+ by (%d+)%.") + if start then + text = string.gsub(text, ".*[iI]ncrease[sd]? ", "") + text = string.gsub(text, " by (%d+)%..*", " %1") + text = string.gsub(text, ",? and ", " " .. value .. "\a") + text = string.gsub(text, ", ", " " .. value .. "\a") + else + text = string.gsub(string.gsub(text, ",? and ", "\a"), ", ", "\a") + end stringTable = { strsplit("\a", text) } for _, statString in pairs(stringTable) do stat = WeightsWatcher:singleStat(statString) if stat then - for name, value in pairs(stat) do - if stats[name] then - stats[name] = stats[name] + value - else - stats[name] = value - end - end + stats = stats + stat end end -- Don't return an empty table -- 1.7.9.5