diff --git a/Regexps.lua b/Regexps.lua
index c65bb34..d67ce64 100644
--- a/Regexps.lua
+++ b/Regexps.lua
@@ -95,14 +95,14 @@ SingleStatLines = {
function(text, pattern)
local start, _, value, name = string.find(text, pattern)
if start then
- return setmetatable({[name] = tonumber(value)}, ww_normalStatsMetatable)
+ return WeightsWatcher.newStatTable({[name] = tonumber(value)})
end
end},
{"^Use: Permanently enchants? .* to give %+?(%d+) (%a[%a ]+).",
function(text, pattern)
local start, _, value, name = string.find(text, pattern)
if start then
- return setmetatable({[name] = tonumber(value)}, ww_normalStatsMetatable)
+ return WeightsWatcher.newStatTable({[name] = tonumber(value)})
end
end},
@@ -151,7 +151,7 @@ SingleSlotLines = {
function WeightsWatcher:multipleStats(text)
local stat, stringTable
- local stats = setmetatable({}, ww_normalStatsMetatable)
+ local stats = WeightsWatcher.newStatTable()
start, _, value = string.find(text, " and %a[%a ]+ by (%d+)%.")
if start then
@@ -177,7 +177,7 @@ end
function WeightsWatcher:damageRange(textL, textR)
local speed
- local stats = setmetatable({}, ww_normalStatsMetatable)
+ local stats = WeightsWatcher.newStatTable()
local start, _, added, minVal, maxVal, name = string.find(textL, "^(%+?)(%d+) %- (%d+) (%a* ?Damage)$")
if start then
if added == "+" then
@@ -212,7 +212,7 @@ function WeightsWatcher:singleStat(text)
else
start, _, name, value = string.find(text, regex)
if start then
- stat = setmetatable({[name] = tonumber(value)}, ww_normalStatsMetatable)
+ stat = WeightsWatcher.newStatTable({[name] = tonumber(value)})
break
end
end
@@ -223,6 +223,10 @@ end
function WeightsWatcher:singleStatValueOnly(text, pattern, name)
local start, _, value = string.find(text, pattern)
if start then
- return setmetatable({[name] = tonumber(value)}, ww_normalStatsMetatable)
+ return WeightsWatcher.newStatTable({[name] = tonumber(value)})
end
end
+
+function WeightsWatcher.newStatTable(tbl)
+ return setmetatable(tbl or {}, ww_normalStatsMetatable)
+end
diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua
index c9508e9..a8d1dc1 100644
--- a/WeightsWatcher.lua
+++ b/WeightsWatcher.lua
@@ -880,7 +880,7 @@ end
function WeightsWatcher:getItemStats(link)
local ttleft, ttright, origTextL, textL, textR, pattern, func, start
- local normalStats, socketList, socketBonusStat = setmetatable({}, ww_normalStatsMetatable), {}
+ local normalStats, socketList, socketBonusStat = WeightsWatcher.newStatTable(), {}
local ranged = false
-- Populate hidden tooltip