From aa9f402f770557e8f28aefdac83c7745427db68c Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Thu, 17 Dec 2009 14:29:45 -0600 Subject: [PATCH] Fixed a lot of metatable stuff --- WeightsWatcher.lua | 4 +--- config.lua | 2 +- config.xml | 8 ++++---- weights.lua | 16 ++++------------ 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua index 1ca4f93..be29ed7 100644 --- a/WeightsWatcher.lua +++ b/WeightsWatcher.lua @@ -94,9 +94,7 @@ ww_weightCacheMetatable = { ww_weightIdealCacheWeightMetatable = { __index = function(tbl, key) - if key == "weight" then - return nil - elseif key == "bestGems" then + if key == "bestGems" then local redScore, yellowScore, blueScore, overallScore local bestGems = {} diff --git a/config.lua b/config.lua index 5f3b1bd..84e6a0a 100644 --- a/config.lua +++ b/config.lua @@ -58,7 +58,7 @@ end function GemQualityDropDownOnClick(choice, dropdown) UIDropDownMenu_SetSelectedValue(dropdown, choice.value, false) ww_vars.options.gemQualityLimit = choice.value - ww_weightIdealCache = {} + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) end function ModifierKeyDropDownInitialize(dropdown) diff --git a/config.xml b/config.xml index 0ca1c6f..337ad06 100644 --- a/config.xml +++ b/config.xml @@ -161,7 +161,7 @@ ww_vars.options.breakSocketColors = true self:GetParent().alwaysObeySocketColors:Disable() end - ww_weightIdealCache = {} + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) GameTooltip:SetOwner(self,"ANCHOR_RIGHT") @@ -197,7 +197,7 @@ else ww_vars.options.neverBreakSocketColors = false end - ww_weightIdealCache = {} + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) self.text:SetTextColor(0.5, 0.5, 0.5) @@ -246,8 +246,8 @@ else ww_vars.options.normalizeWeights = false end - ww_weightCache = {} - ww_weightIdealCache = {} + ww_weightCache = setmetatable({}, ww_weightCacheMetatable) + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) GameTooltip:SetOwner(self,"ANCHOR_RIGHT") diff --git a/weights.lua b/weights.lua index b5d7bdd..b6ec9b2 100644 --- a/weights.lua +++ b/weights.lua @@ -41,12 +41,8 @@ StaticPopupDialogs["WW_CONFIRM_RESTORE_DEFAULTS"] = { for _, class in ipairs(defaultVars.weightsList) do for _, weight in ipairs(defaultVars.weightsList[class]) do setWeight(class, weight, defaultVars.weightsList[class][weight]) - if ww_weightCache[class] then - ww_weightCache[class][weight] = {} - end - if ww_weightIdealCache[class] then - ww_weightIdealCache[class][weight] = {} - end + ww_weightCache[class][weight] = nil + ww_weightIdealCache[class][weight] = nil end end if ww_weights.rightPanel:IsShown() then @@ -257,12 +253,8 @@ function configSaveWeight() local weightFrame = ww_weights.rightPanel.weightFrame -- The weight is changing, clear any cached info - if ww_weightCache[weightFrame.category.class] then - ww_weightCache[weightFrame.category.class][weightFrame.name] = {} - end - if ww_weightIdealCache[weightFrame.category.class] then - ww_weightIdealCache[weightFrame.category.class][weightFrame.name] = {} - end + ww_weightCache[weightFrame.category.class][weightFrame.name] = nil + ww_weightIdealCache[weightFrame.category.class][weightFrame.name] = nil for statValue, statName in pairs(ww_weights.rightPanel.changedStats) do number = statValue:GetNumber() -- 1.7.9.5