Pass the item slot to the weight function and fix an error when opening interface options instead of using /dress config
James Whitehead II [08-15-08 - 07:17]
Pass the item slot to the weight function and fix an error when opening interface options instead of using /dress config
diff --git a/DressToKill.lua b/DressToKill.lua
index 3219f61..e88124d 100644
--- a/DressToKill.lua
+++ b/DressToKill.lua
@@ -130,7 +130,7 @@ local function scanFunction(weightFunction)
local equipped = DressToKill:EquipItem(slotId, mask, stash)
if equipped then
local link = GetInventoryItemLink("player", slotId)
- local score = weightFunction(link)
+ local score = weightFunction(link, slotId)
if score >= maxScore then
maxScore = score
winner = mask
@@ -247,7 +247,8 @@ SlashCmdList["DRESSTOKILL"] = function(msg, editbox)
-- Compile the function
local source = DressToKill.profile.weightFuncs[weightName].handler
- local weightFunction,err = loadstring("return function (link) " .. source .. " end")
+ local newsrc = string.format("return function (link, slot) %s end", source)
+ local weightFunction,err = loadstring(newsrc)
if not weightFunction then
print("Failed to compile weight function: " .. tostring(err))
diff --git a/DressToKillOptions.lua b/DressToKillOptions.lua
index 9d0134e..9cb198c 100644
--- a/DressToKillOptions.lua
+++ b/DressToKillOptions.lua
@@ -4,6 +4,8 @@ local frame = CreateFrame("Frame", "DressToKillOptionsFrame", UIParent)
frame.name = L["Dress to Kill"]
frame:Hide()
frame:SetScript("OnShow", function(frame)
+ -- Initialize the system
+ DressToKill:Initialize()
local title = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -15)
title:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)