136 lines
4.1 KiB
Lua
136 lines
4.1 KiB
Lua
local debug = true
|
|
local iconDisplayDuration = 3
|
|
|
|
local function getItemLink(container, slot)
|
|
aura_env.debugLog("getItemLink", container, slot)
|
|
return select(7, GetContainerItemInfo(container, slot))
|
|
end
|
|
local function getItemQuantity(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)
|
|
if (itemLevel and itemBindType and itemLevel < 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(slot)
|
|
local itemName = getItemName(slot)
|
|
local itemQuantity = getItemQuantity(slot)
|
|
local itemQuality = getItemQuality(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 .. "...")
|
|
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
|
|
} |