148 lines
4.7 KiB
Lua
148 lines
4.7 KiB
Lua
local debug = false
|
|
local iconDisplayDuration = 3
|
|
|
|
local function getItemLink(container, slot)
|
|
return select(7, GetContainerItemInfo(container, slot))
|
|
end
|
|
local function getItemQuantity(container, slot)
|
|
return select(2, GetContainerItemInfo(container, slot))
|
|
end
|
|
local function getItemName(container, slot)
|
|
return select(1, GetItemInfo(getItemLink(container, slot)))
|
|
end
|
|
local function getItemType(container, slot)
|
|
return select(6, GetItemInfo(getItemLink(container, slot)))
|
|
end
|
|
local function getItemSubtype(container, slot)
|
|
return select(7, GetItemInfo(getItemLink(container, slot)))
|
|
end
|
|
local function getItemLevel(container, slot)
|
|
return select(4, GetItemInfo(getItemLink(container, slot)))
|
|
end
|
|
local function getItemValue(container, slot)
|
|
return select(11, GetItemInfo(getItemLink(container, slot)))
|
|
end
|
|
local function getItemQuality(container, slot)
|
|
return select(3, GetItemInfo(getItemLink(container, slot)))
|
|
end
|
|
local function getItemEquipLocation(container, slot)
|
|
return select(9, GetItemInfo(getItemLink(container, slot)))
|
|
end
|
|
local function getItemIcon(container, slot)
|
|
return select(10, GetItemInfo(getItemLink(container, slot)))
|
|
end
|
|
local function getBindType(container, slot)
|
|
return select(14, GetItemInfo(getItemLink(container, slot)))
|
|
end
|
|
|
|
|
|
|
|
local grayFilter = {
|
|
enabled = true,
|
|
filter = function(self, container, slot)
|
|
if (self.enabled) then
|
|
aura_env.debugLog("Gray filter; container = " .. container .. ", slot = " .. slot)
|
|
local itemQuality = getItemQuality(container, slot)
|
|
if (itemQuality and itemQuality == 0) then
|
|
aura_env.debugLog("Gray filter pass")
|
|
return true
|
|
end
|
|
end
|
|
end
|
|
}
|
|
local gearFilter = {
|
|
enabled = true,
|
|
ilvlThreshold = 850,
|
|
sellBoe = false,
|
|
filter = function(self, container, slot)
|
|
if (self.enabled) then
|
|
aura_env.debugLog("Gear filter; container = " .. container .. ", slot = " .. slot)
|
|
local itemLevel = getItemLevel(container, slot)
|
|
local itemBindType = getBindType(container, slot)
|
|
local itemType = getItemType(container, slot)
|
|
local itemEquipLoc = getItemEquipLocation(container, slot)
|
|
if (itemType and itemEquipLoc and
|
|
(itemType == "Armor"
|
|
or itemType == "Weapon"
|
|
or itemEquipLoc == "INVTYPE_FINGER"
|
|
or itemEquipLoc == "INVTYPE_TRINKET"
|
|
or itemEquipLoc == "INVTYPE_CLOAK"
|
|
or itemEquipLoc == "INVTYPE_NECK")
|
|
and itemLevel and itemBindType and itemLevel < self.ilvlThreshold and (itemBindType == 1 or self.sellBoe)) then
|
|
aura_env.debugLog("Gear filter pass")
|
|
return true
|
|
end
|
|
end
|
|
end
|
|
}
|
|
|
|
local function doSell(container, slot)
|
|
local itemIcon = getItemIcon(container, slot)
|
|
local itemName = getItemName(container, slot)
|
|
local itemQuantity = getItemQuantity(container, slot)
|
|
local itemQuality = getItemQuality(container, slot)
|
|
|
|
aura_env.debugLog("Drawing icon for " .. itemName .. " with quality " .. itemQuality)
|
|
local nameWithColor = aura_env.qualityColors[itemQuality + 1] .. "[" .. itemName .. "]\124r"
|
|
local nameWithQuantity = nameWithColor .. " x" .. itemQuantity
|
|
|
|
aura_env.debugLog("Assigning name" .. nameWithQuantity)
|
|
aura_env.allstates[#aura_env.allstates + 1] = {
|
|
show = true,
|
|
changed = true,
|
|
index = GetTime(),
|
|
resort = true,
|
|
|
|
icon = itemIcon,
|
|
name = nameWithQuantity,
|
|
amount = itemQuantity,
|
|
|
|
progressType = "timed",
|
|
expirationTime = GetTime() + iconDisplayDuration,
|
|
duration = iconDisplayDuration,
|
|
autoHide = true,
|
|
}
|
|
|
|
UseContainerItem(container, slot)
|
|
end
|
|
|
|
|
|
aura_env.filterService = {
|
|
filters = {
|
|
grayFilter,
|
|
gearFilter,
|
|
},
|
|
slotsToLoot = {},
|
|
run = function(self, container, slot)
|
|
aura_env.debugLog("Filtering item in container = " .. container .. ", slot = " .. slot .. "...")
|
|
if (not getItemLink(container, slot)) then
|
|
aura_env.debugLog("Slot empty")
|
|
return
|
|
end
|
|
for k, filter in pairs(self.filters) do
|
|
if (filter:filter(container, slot)) then
|
|
doSell(container, slot)
|
|
return
|
|
end
|
|
end
|
|
end
|
|
}
|
|
|
|
aura_env.debugLog = function(obj)
|
|
if (debug) then
|
|
print(GetTime())
|
|
DevTools_Dump(obj)
|
|
print()
|
|
end
|
|
end
|
|
|
|
aura_env.qualityColors = {
|
|
"\124cff9d9d9d", -- Poor
|
|
"\124cffffffff", -- Common
|
|
"\124cff1eff00", -- Uncommon
|
|
"\124cff0070dd", -- Rare
|
|
"\124cffa335ee", -- Epic
|
|
"\124cffff8000", -- Legendary
|
|
"\124cffe6cc80", -- Artifact
|
|
"\124cff00ccff", -- Heirloom
|
|
} |