Add some error checking
This commit is contained in:
@@ -4,6 +4,6 @@ function(allstates, e)
|
||||
|
||||
local lootInfo = GetLootInfo()
|
||||
aura_env.filterService:run(lootInfo)
|
||||
CloseLoot()
|
||||
-- CloseLoot()
|
||||
return true
|
||||
end
|
||||
|
||||
1
LegionWA/NewAutoLoot/Export
Normal file
1
LegionWA/NewAutoLoot/Export
Normal file
File diff suppressed because one or more lines are too long
@@ -3,6 +3,7 @@ local iconDisplayDuration = 3
|
||||
|
||||
-- itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType,itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType,expacID, setID, isCraftingReagent = GetItemInfo(slot)
|
||||
-- lootIcon, lootName, lootQuantity, currencyID, lootQuality, locked, isQuestItem, questID, isActive = GetLootSlotInfo(slot)
|
||||
-- Link sometimes does not work
|
||||
local function getItemLink(slot)
|
||||
return GetLootSlotLink(slot)
|
||||
end
|
||||
@@ -73,7 +74,7 @@ local goldFilter = {
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Gold filter; slot: " .. slot)
|
||||
local itemName = getItemName(slot)
|
||||
if (itemName:match("%d+ (Gold|Silver|Copper)")) then
|
||||
if (itemname and itemName:match("%d+ (Gold|Silver|Copper)")) then
|
||||
aura_env.debugLog("Gold filter pass")
|
||||
return true
|
||||
end
|
||||
@@ -86,7 +87,7 @@ local orderResourcesFilter = {
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Resource filter; slot: " .. slot)
|
||||
local itemName = getItemName(slot)
|
||||
if (itemName:match("Order Resources")) then
|
||||
if (itemName and itemName:match("Order Resources")) then
|
||||
aura_env.debugLog("Order resource filter pass")
|
||||
return true
|
||||
end
|
||||
@@ -99,7 +100,7 @@ local mountFilter = {
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Mount filter; slot: " .. slot)
|
||||
local itemType = getItemType(slot)
|
||||
if (itemType == "Mount") then
|
||||
if (itemType and itemType == "Mount") then
|
||||
aura_env.debugLog("Mount filter pass")
|
||||
return true
|
||||
end
|
||||
@@ -113,7 +114,7 @@ local ilvlFilter = {
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("ILvl filter; slot: " .. slot)
|
||||
local itemLevel = getItemLevel(slot)
|
||||
if (itemLevel > self.ilvlThreshold) then
|
||||
if (itemLevel and itemLevel > self.ilvlThreshold) then
|
||||
aura_env.debugLog("Item level filter pass")
|
||||
return true
|
||||
end
|
||||
@@ -131,13 +132,13 @@ local professionFilter = {
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Profession filter; slot: " .. slot)
|
||||
local itemType = getItemType(slot)
|
||||
if (itemType == "Tradeskill") then
|
||||
if (itemType and itemType == "Tradeskill") then
|
||||
local itemSubtype = getItemSubtype(slot)
|
||||
if (itemSubtype == "Herb" and self.herbs)
|
||||
if (itemSubtype and (itemSubtype == "Herb" and self.herbs)
|
||||
or (itemSubtype == "Leather" and self.leather)
|
||||
or (itemSubtype == "Cloth" and self.cloth)
|
||||
or (itemSubtype == "Ore" and self.ore)
|
||||
or (itemSubtype == "Cooking" and self.cooking) then
|
||||
or (itemSubtype == "Cooking" and self.cooking)) then
|
||||
aura_env.debugLog("Profession filter pass")
|
||||
return true
|
||||
end
|
||||
@@ -160,7 +161,7 @@ local valueFilter = {
|
||||
itemValue = itemValue * itemQuantity
|
||||
end
|
||||
|
||||
if (itemValue > self.valueThreshold) then
|
||||
if (itemValue and itemValue > self.valueThreshold) then
|
||||
aura_env.debugLog("Value filter pass")
|
||||
return true
|
||||
end
|
||||
@@ -185,7 +186,7 @@ local greyValueFilter = {
|
||||
itemValue = itemValue * itemQuantity
|
||||
end
|
||||
|
||||
if (itemValue > self.valueThreshold) then
|
||||
if (itemValue and itemValue > self.valueThreshold) then
|
||||
aura_env.debugLog("Grey value filter pass")
|
||||
return true
|
||||
end
|
||||
@@ -200,7 +201,7 @@ local questItemFilter = {
|
||||
aura_env.debugLog("Quest item filter; slot: " .. slot)
|
||||
local itemType = getItemType(slot)
|
||||
local itemSubtype = getItemSubtype(slot)
|
||||
if (itemType == itemSubtype == "Quest") then
|
||||
if (itemType and itemSubtype and itemType == itemSubtype == "Quest") then
|
||||
aura_env.debugLog("Quest item filter pass")
|
||||
return true
|
||||
end
|
||||
@@ -234,6 +235,23 @@ local classGearFilter = {
|
||||
end
|
||||
end
|
||||
}
|
||||
local azeriteFilter = {
|
||||
enabled = true,
|
||||
ilvlThreshold = 800,
|
||||
qualityThreshold = 2,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Azerite filter; slot: " .. slot)
|
||||
local itemType = getItemType(slot)
|
||||
local itemSubtype = getItemSubtype(slot)
|
||||
local itemQuality = getItemQuality(slot)
|
||||
if (itemType and itemSubtype and itemQuality and itemType == "Consumable" and itemSubtype == "Other" and itemQuality > 1) then
|
||||
aura_env.debugLog("Azerite filter pass")
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
aura_env.filterService = {
|
||||
filters = {
|
||||
@@ -245,18 +263,16 @@ aura_env.filterService = {
|
||||
valueFilter,
|
||||
greyValueFilter,
|
||||
questItemFilter,
|
||||
classGearFilter
|
||||
classGearFilter,
|
||||
azeriteFilter
|
||||
},
|
||||
slotsToLoot = {},
|
||||
run = function(self, lootInfo)
|
||||
self.slotsToLoot = {}
|
||||
for slot, item in pairs(lootInfo) do
|
||||
aura_env.debugLog("Loot slot: " .. slot .. " " .. item.item)
|
||||
for k, filter in pairs(self.filters) do
|
||||
if (filter:filter(slot)) then
|
||||
self.slotsToLoot[#self.slotsToLoot + 1] = slot
|
||||
end
|
||||
end
|
||||
aura_env.debugLog(getItemSubtype(slot))
|
||||
self:runFilters(slot)
|
||||
end
|
||||
|
||||
aura_env.debugLog("Slots to loot: " .. #self.slotsToLoot)
|
||||
@@ -266,6 +282,14 @@ aura_env.filterService = {
|
||||
aura_env.debugLog("Looting slot (iterator): " .. slot)
|
||||
doLoot(slot)
|
||||
end
|
||||
end,
|
||||
runFilters = function(self, slot)
|
||||
for k, filter in pairs(self.filters) do
|
||||
if (filter:filter(slot)) then
|
||||
self.slotsToLoot[#self.slotsToLoot + 1] = slot
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user