Add more error handling and ancient mana filter
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -14,19 +14,27 @@ local function getItemName(slot)
|
||||
end
|
||||
local function getItemType(slot)
|
||||
if (slot == nil) then return nil end
|
||||
return select(6, GetItemInfo(getItemLink(slot)))
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(6, GetItemInfo(itemLink))
|
||||
end
|
||||
local function getItemSubtype(slot)
|
||||
if (slot == nil) then return nil end
|
||||
return select(7, GetItemInfo(getItemLink(slot)))
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(7, GetItemInfo(itemLink))
|
||||
end
|
||||
local function getItemLevel(slot)
|
||||
if (slot == nil) then return nil end
|
||||
return select(4, GetItemInfo(getItemLink(slot)))
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(4, GetItemInfo(itemLink))
|
||||
end
|
||||
local function getItemValue(slot)
|
||||
if (slot == nil) then return nil end
|
||||
return select(11, GetItemInfo(getItemLink(slot)))
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(11, GetItemInfo(itemLink))
|
||||
end
|
||||
local function getItemQuantity(slot)
|
||||
if (slot == nil) then return nil end
|
||||
@@ -34,15 +42,21 @@ local function getItemQuantity(slot)
|
||||
end
|
||||
local function getItemQuality(slot)
|
||||
if (slot == nil) then return nil end
|
||||
return select(3, GetItemInfo(getItemLink(slot)))
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(3, GetItemInfo(itemLink))
|
||||
end
|
||||
local function getItemEquipLocation(slot)
|
||||
if (slot == nil) then return nil end
|
||||
return select(9, GetItemInfo(getItemLink(slot)))
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(9, GetItemInfo(itemLink))
|
||||
end
|
||||
local function getItemIcon(slot)
|
||||
if (slot == nil) then return nil end
|
||||
return select(10, GetItemInfo(getItemLink(slot)))
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(10, GetItemInfo(itemLink))
|
||||
end
|
||||
|
||||
|
||||
@@ -50,10 +64,11 @@ local doLoot = function(slot)
|
||||
aura_env.debugLog("Looting slot: " .. slot)
|
||||
LootSlot(slot)
|
||||
|
||||
local itemIcon = getItemIcon(slot)
|
||||
local itemName = getItemName(slot)
|
||||
local itemQuantity = getItemQuantity(slot)
|
||||
local itemQuality = getItemQuality(slot)
|
||||
local itemIcon = getItemIcon(slot) or 134400
|
||||
local itemName = getItemName(slot) or "Unknown"
|
||||
itemName = itemName:gsub("\n", ", ")
|
||||
local itemQuantity = getItemQuantity(slot) or 1
|
||||
local itemQuality = getItemQuality(slot) or 0
|
||||
|
||||
aura_env.debugLog("Drawing icon for " .. itemName .. " with quality " .. itemQuality)
|
||||
local nameWithColor = aura_env.qualityColors[itemQuality + 1] .. "[" .. itemName .. "]\124r"
|
||||
@@ -84,7 +99,9 @@ local goldFilter = {
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Gold filter; slot: " .. slot)
|
||||
local itemName = getItemName(slot)
|
||||
if (itemname and itemName:match("%d+ (Gold|Silver|Copper)")) then
|
||||
-- I guess it does not support OR in regex?
|
||||
-- itemName:match("%d+ ((Gold)|(Silver)|(Copper))")
|
||||
if (itemname and itemName:match("%d+ Gold") or itemName:match("%d+ Silver") or itemName:match("%d+ Copper")) then
|
||||
aura_env.debugLog("Gold filter pass")
|
||||
return true
|
||||
end
|
||||
@@ -187,7 +204,7 @@ local greyValueFilter = {
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Grey value filter; slot: " .. slot)
|
||||
local itemQuality = getItemQuality(slot)
|
||||
if (itemQuality > 0) then
|
||||
if (itemQuality and itemQuality > 0) then
|
||||
local itemValue = getItemValue(slot)
|
||||
|
||||
if (self.applyThresholdToItemStack) then
|
||||
@@ -277,6 +294,20 @@ local arguniteFilter = {
|
||||
end
|
||||
end
|
||||
}
|
||||
local ancientManaFilter = {
|
||||
enabled = true,
|
||||
qualityThreshold = 1,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Ancient mana filter; slot: " .. slot)
|
||||
local itemName = getItemName(slot)
|
||||
if (itemName and itemName:match("Ancient Mana")) then
|
||||
aura_env.debugLog("Ancient mana filter pass")
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
aura_env.filterService = {
|
||||
filters = {
|
||||
@@ -290,14 +321,14 @@ aura_env.filterService = {
|
||||
questItemFilter,
|
||||
classGearFilter,
|
||||
azeriteFilter,
|
||||
arguniteFilter
|
||||
arguniteFilter,
|
||||
ancientManaFilter
|
||||
},
|
||||
slotsToLoot = {},
|
||||
run = function(self, lootInfo)
|
||||
self.slotsToLoot = {}
|
||||
for slot, item in pairs(lootInfo) do
|
||||
aura_env.debugLog("Loot slot: " .. slot .. " " .. item.item)
|
||||
aura_env.debugLog(getItemSubtype(slot))
|
||||
self:runFilters(slot)
|
||||
end
|
||||
|
||||
@@ -312,6 +343,7 @@ aura_env.filterService = {
|
||||
runFilters = function(self, slot)
|
||||
for k, filter in pairs(self.filters) do
|
||||
if (filter:filter(slot)) then
|
||||
-- Might be good to, instead of just adding slot to a list, add an object with info about the item and the slot containing it so each filter can dictate the item name and icon
|
||||
self.slotsToLoot[#self.slotsToLoot + 1] = slot
|
||||
return
|
||||
end
|
||||
|
Reference in New Issue
Block a user