Fix issues with autoloot
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
-- LOOT_READY
|
||||
function(e)
|
||||
local lootInfo = GetLootInfo()
|
||||
print(aura_env.filterService)
|
||||
aura_env.FilterService.Run(lootInfo)
|
||||
CloseLoot()
|
||||
C_Timer.After(0.1, function()
|
||||
WeakAuras.ScanEvents("DO_AUTOLOOT")
|
||||
end)
|
||||
end
|
||||
|
||||
6
LegionWA/AutoLoot/Event2.lua
Normal file
6
LegionWA/AutoLoot/Event2.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
-- DO_AUTOLOOT
|
||||
function(e)
|
||||
local lootInfo = GetLootInfo()
|
||||
aura_env.FilterService.Run(lootInfo)
|
||||
CloseLoot()
|
||||
end
|
||||
@@ -4,87 +4,98 @@ if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
||||
if not WeakAurasSaved.Cyka.ItemCache then WeakAurasSaved.Cyka.ItemCache = {} end
|
||||
|
||||
---@param slot number
|
||||
---@return string
|
||||
---@return string, string|nil
|
||||
local function getItemLink(slot)
|
||||
if slot == nil then return "" end
|
||||
return GetLootSlotLink(slot)
|
||||
if slot == nil then return "", string.format("Slot can not be nil") end
|
||||
local link = GetLootSlotLink(slot)
|
||||
if link == nil then return "", string.format("GetLootSlotLink returned nil for slot %d", slot) end
|
||||
return link, nil
|
||||
end
|
||||
---@param slot number
|
||||
---@return string
|
||||
---@return string, string|nil
|
||||
local function getItemName(slot)
|
||||
if slot == nil then return "" end
|
||||
return select(2, GetLootSlotInfo(slot))
|
||||
if slot == nil then return "", string.format("Slot can not be null") end
|
||||
return select(2, GetLootSlotInfo(slot)), nil
|
||||
end
|
||||
---@param slot number
|
||||
---@return string
|
||||
---@return string, string|nil
|
||||
local function getItemType(slot)
|
||||
if slot == nil then return "" end
|
||||
local itemLink = getItemLink(slot)
|
||||
return select(6, GetItemInfo(itemLink))
|
||||
if slot == nil then return "", string.format("Slot can not be nil") end
|
||||
local itemLink, err = getItemLink(slot)
|
||||
if err then return "", err end
|
||||
return select(6, GetItemInfo(itemLink)), nil
|
||||
end
|
||||
---@param slot number
|
||||
---@return string
|
||||
---@return string, string|nil
|
||||
local function getItemSubtype(slot)
|
||||
if slot == nil then return "" end
|
||||
local itemLink = getItemLink(slot)
|
||||
return select(7, GetItemInfo(itemLink))
|
||||
if slot == nil then return "", string.format("Slot can not be nil") end
|
||||
local itemLink, err = getItemLink(slot)
|
||||
if err then return "", err end
|
||||
return select(7, GetItemInfo(itemLink)), nil
|
||||
end
|
||||
---@param slot number
|
||||
---@return number
|
||||
---@return number, string|nil
|
||||
local function getItemLevel(slot)
|
||||
if slot == nil then return 0 end
|
||||
local itemLink = getItemLink(slot)
|
||||
return select(4, GetItemInfo(itemLink))
|
||||
if slot == nil then return 0, string.format("Slot can not be nil") end
|
||||
local itemLink, err = getItemLink(slot)
|
||||
if err then return 0, err end
|
||||
return select(4, GetItemInfo(itemLink)), nil
|
||||
end
|
||||
|
||||
---The vendor price in copper, or 0 for items that cannot be sold
|
||||
---@param slot number
|
||||
---@return number
|
||||
---@return number, string|nil
|
||||
local function getItemValue(slot)
|
||||
if slot == nil then return 0 end
|
||||
local itemLink = getItemLink(slot)
|
||||
return select(11, GetItemInfo(itemLink))
|
||||
if slot == nil then return 0, string.format("Slot can not be nil") end
|
||||
local itemLink, err = getItemLink(slot)
|
||||
if err then return 0, err end
|
||||
return select(11, GetItemInfo(itemLink)), nil
|
||||
end
|
||||
---@param slot number
|
||||
---@return number
|
||||
---@return number, string|nil
|
||||
local function getItemSubclassId(slot)
|
||||
if slot == nil then return 0 end
|
||||
local itemLink = getItemLink(slot)
|
||||
return select(13, GetItemInfo(itemLink))
|
||||
if slot == nil then return 0, string.format("Slot can not be nil") end
|
||||
local itemLink, err = getItemLink(slot)
|
||||
if err then return 0, err end
|
||||
return select(13, GetItemInfo(itemLink)), nil
|
||||
end
|
||||
---@param slot number
|
||||
---@return number
|
||||
---@return number, string|nil
|
||||
local function getItemQuantity(slot)
|
||||
if slot == nil then return 0 end
|
||||
return select(3, GetLootSlotInfo(slot))
|
||||
if slot == nil then return 0, string.format("Slot can not be nil") end
|
||||
return select(3, GetLootSlotInfo(slot)), nil
|
||||
end
|
||||
---@param slot number
|
||||
---@return Enum.ItemQuality
|
||||
---@return Enum.ItemQuality, string|nil
|
||||
local function getItemQuality(slot)
|
||||
if slot == nil then return Enum.ItemQuality.Poor end
|
||||
local itemLink = getItemLink(slot)
|
||||
return select(3, GetItemInfo(itemLink))
|
||||
if slot == nil then return 0, string.format("Slot can not be nil") end
|
||||
local itemLink, err = getItemLink(slot)
|
||||
if err then return 0, err end
|
||||
return select(3, GetItemInfo(itemLink)), nil
|
||||
end
|
||||
---@param slot number
|
||||
---@return string
|
||||
---@return string, string|nil
|
||||
local function getItemEquipLocation(slot)
|
||||
if slot == nil then return "" end
|
||||
local itemLink = getItemLink(slot)
|
||||
return select(9, GetItemInfo(itemLink))
|
||||
if slot == nil then return "", string.format("Slot can not be nil") end
|
||||
local itemLink, err = getItemLink(slot)
|
||||
if err then return "", err end
|
||||
return select(9, GetItemInfo(itemLink)), nil
|
||||
end
|
||||
---@param slot number
|
||||
---@return number
|
||||
---@return number, string|nil
|
||||
local function getItemIcon(slot)
|
||||
if slot == nil then return 0 end
|
||||
local itemLink = getItemLink(slot)
|
||||
return select(10, GetItemInfo(itemLink))
|
||||
if slot == nil then return 134400, string.format("Slot can not be nil") end
|
||||
local itemLink, err = getItemLink(slot)
|
||||
if err then return 134400, err end
|
||||
return select(10, GetItemInfo(itemLink)), nil
|
||||
end
|
||||
---@param slot number
|
||||
---@return number
|
||||
---@return number, string|nil
|
||||
local function getBindType(slot)
|
||||
if slot == nil then return 0 end
|
||||
local itemLink = getItemLink(slot)
|
||||
return select(14, GetItemInfo(itemLink))
|
||||
if slot == nil then return 0, string.format("Slot can not be nil") end
|
||||
local itemLink, err = getItemLink(slot)
|
||||
if err then return 0, err end
|
||||
return select(14, GetItemInfo(itemLink)), nil
|
||||
end
|
||||
|
||||
---@class Filter
|
||||
@@ -108,16 +119,25 @@ Filter = {
|
||||
|
||||
---@param self Filter
|
||||
---@param slot number
|
||||
---@return boolean
|
||||
---@return boolean, string|nil
|
||||
Run = function(self, slot)
|
||||
---@type table<string, string|number|boolean>
|
||||
local provided = {}
|
||||
if self.requires then
|
||||
for k, v in pairs(self.requires) do
|
||||
provided[k] = v(slot)
|
||||
local res, err = v(slot)
|
||||
if err ~= nil then
|
||||
if debug then print(err) end
|
||||
else
|
||||
provided[k] = res
|
||||
end
|
||||
end
|
||||
return self.filter(slot, provided)
|
||||
end
|
||||
local res, err = self.filter(slot, provided)
|
||||
if err ~= nil then
|
||||
if debug then print(err) end
|
||||
end
|
||||
return res, nil
|
||||
end
|
||||
}
|
||||
|
||||
@@ -128,8 +148,10 @@ local goldFilter = Filter.new(true,
|
||||
if string.find(provided.name, "Gold") or
|
||||
string.find(provided.name, "Silver") or
|
||||
string.find(provided.name, "Copper") then
|
||||
if debug then print(string.format("Gold filter pass for %s", provided.name)) end
|
||||
return true
|
||||
end
|
||||
if debug then print(string.format("Gold filter fail for %s", provided.name)) end
|
||||
return false
|
||||
end)
|
||||
local orderResourcesFilter = Filter.new(true,
|
||||
@@ -137,8 +159,10 @@ local orderResourcesFilter = Filter.new(true,
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if string.find(provided.name, "Order Resources") then
|
||||
if debug then print(string.format("Order resource filter pass for %s", provided.name)) end
|
||||
return true
|
||||
end
|
||||
if debug then print(string.format("Order resource filter fail for %s", provided.name)) end
|
||||
return false
|
||||
end)
|
||||
local mountFilter = Filter.new(true,
|
||||
@@ -146,8 +170,10 @@ local mountFilter = Filter.new(true,
|
||||
function(slot, provided)
|
||||
---@cast provided { type: string }
|
||||
if provided.type == "Mount" then
|
||||
if debug then print(string.format("Mount filter pass for type %s", provided.type)) end
|
||||
return true
|
||||
end
|
||||
if debug then print(string.format("Mount filter fail for type %s", provided.type)) end
|
||||
return false
|
||||
end)
|
||||
local ilvlFilter = Filter.new(true,
|
||||
@@ -155,8 +181,10 @@ local ilvlFilter = Filter.new(true,
|
||||
function(slot, provided)
|
||||
---@cast provided { ilvl: number }
|
||||
if provided.ilvl and provided.ilvl > 800 then
|
||||
if debug then print(string.format("ilvl filter pass for ilvl %d", provided.ilvl)) end
|
||||
return true
|
||||
end
|
||||
if debug then print(string.format("ilvl filter fail for ilvl %d", provided.ilvl)) end
|
||||
return false
|
||||
end)
|
||||
local professionFilter = Filter.new(true,
|
||||
@@ -179,9 +207,11 @@ local professionFilter = Filter.new(true,
|
||||
|
||||
if provided.type == "Tradeskill" then
|
||||
if enabled[provided.subtype] then
|
||||
if debug then print(string.format("Profession filter pass for type %s", provided.type)) end
|
||||
return true
|
||||
end
|
||||
end
|
||||
if debug then print(string.format("Profession filter fail for type %s", provided.type)) end
|
||||
return false
|
||||
end)
|
||||
local valueFilter = Filter.new(true,
|
||||
@@ -199,8 +229,10 @@ local valueFilter = Filter.new(true,
|
||||
if applyValueTostack then value = value * provided.quantity end
|
||||
|
||||
if value > valueThreshold then
|
||||
if debug then print(string.format("Value filter pass for value %d", value)) end
|
||||
return true
|
||||
end
|
||||
if debug then print(string.format("Value filter fail for value %d", value)) end
|
||||
return false
|
||||
end)
|
||||
local greyValueFilter = Filter.new(true,
|
||||
@@ -220,9 +252,17 @@ local greyValueFilter = Filter.new(true,
|
||||
if applyValueTostack then value = value * provided.quantity end
|
||||
|
||||
if value > valueThreshold then
|
||||
if debug then
|
||||
print(string.format("Grey value filter pass for value %d of %s quality items", value,
|
||||
provided.quality))
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
if debug then
|
||||
print(string.format("Grey value filter fail for value %d of %s quality items", provided.value,
|
||||
provided.quality))
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local questItemFilter = Filter.new(true,
|
||||
@@ -233,8 +273,16 @@ local questItemFilter = Filter.new(true,
|
||||
function(slot, provided)
|
||||
---@cast provided { type: string, subtype: string }
|
||||
if provided.type == "Quest" and provided.subtype == "Quest" then
|
||||
if debug then
|
||||
print(string.format("Quest item filter pass for type %s and subtype", provided.type,
|
||||
provided.subtype))
|
||||
end
|
||||
return true
|
||||
end
|
||||
if debug then
|
||||
print(string.format("Quest item filter fail for type %s and subtype", provided.type,
|
||||
provided.subtype))
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local classGearFilter = Filter.new(true,
|
||||
@@ -254,8 +302,16 @@ local classGearFilter = Filter.new(true,
|
||||
local isEquippable = aura_env.skills[select(3, UnitClass("player"))][provided.subtype] == 1
|
||||
|
||||
if isEquippable and provided.ilvl > ilvlThreshold and provided.quality > qualityThreshold then
|
||||
if debug then
|
||||
print(string.format("Class gear filter pass for ilvl %d and quality %d", provided.ilvl,
|
||||
provided.quality))
|
||||
end
|
||||
return true
|
||||
end
|
||||
if debug then
|
||||
print(string.format("Class gear filter fail for ilvl %d and quality %d", provided.ilvl,
|
||||
provided.quality))
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local arguniteFilter = Filter.new(true,
|
||||
@@ -266,8 +322,13 @@ local arguniteFilter = Filter.new(true,
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string, quality: number }
|
||||
if string.find(provided.name, "Argunite") and provided.quality > 1 then
|
||||
if debug then
|
||||
print(string.format("Argunite filter pass for %s and quality %d", provided.name,
|
||||
provided.quality))
|
||||
end
|
||||
return true
|
||||
end
|
||||
if debug then print(string.format("Argunite filter fail for %s and quality %d", provided.name, provided.quality)) end
|
||||
return false
|
||||
end)
|
||||
local ancientManaFilter = Filter.new(true,
|
||||
@@ -275,8 +336,10 @@ local ancientManaFilter = Filter.new(true,
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if string.find(provided.name, "Ancient Mana") then
|
||||
if debug then print(string.format("Ancient Mana filter pass for %s", provided.name)) end
|
||||
return true
|
||||
end
|
||||
if debug then print(string.format("Ancient Mana filter fail for %s", provided.name)) end
|
||||
return false
|
||||
end)
|
||||
local reicpeFilter = Filter.new(false,
|
||||
@@ -284,8 +347,10 @@ local reicpeFilter = Filter.new(false,
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if string.find(provided.name, "Recipe") or string.find(provided.name, "Technique") then
|
||||
if debug then print(string.format("Recipe filter pass for %s", provided.name)) end
|
||||
return true
|
||||
end
|
||||
if debug then print(string.format("Recipe filter fail for %s", provided.name)) end
|
||||
return false
|
||||
end)
|
||||
local bloodOfSargerasFilter = Filter.new(true,
|
||||
@@ -293,8 +358,10 @@ local bloodOfSargerasFilter = Filter.new(true,
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if provided.name == "Blood of Sargeras" then
|
||||
if debug then print(string.format("Blood of Sargeras filter pass for %s", provided.name)) end
|
||||
return true
|
||||
end
|
||||
if debug then print(string.format("Blood of Sargeras filter fail for %s", provided.name)) end
|
||||
return false
|
||||
end)
|
||||
local bloodhunerQuarryFilter = Filter.new(true,
|
||||
@@ -302,8 +369,10 @@ local bloodhunerQuarryFilter = Filter.new(true,
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if provided.name == "Bloodhunter's Quarry" then
|
||||
if debug then print(string.format("Bloodhunter's Quarry filter pass for %s", provided.name)) end
|
||||
return true
|
||||
end
|
||||
if debug then print(string.format("Bloodhunter's Quarry filter fail for %s", provided.name)) end
|
||||
return false
|
||||
end)
|
||||
local boeFilter = Filter.new(true,
|
||||
@@ -333,23 +402,72 @@ local boeFilter = Filter.new(true,
|
||||
local bindType = provided.bindtype
|
||||
|
||||
if itemLevel > ilvlThreshold and itemQuality > qualityThreshold and bindType == 1 then
|
||||
if debug then print(string.format("BoE filter pass for ilvl %d and quality %d", itemLevel, itemQuality)) end
|
||||
return true
|
||||
end
|
||||
end
|
||||
if debug then print(string.format("BoE filter fail for ilvl %d and quality %d", provided.ilvl, provided.quality)) end
|
||||
return false
|
||||
end)
|
||||
local artifactPowerFilter = Filter.new(true, {
|
||||
["type"] = getItemType,
|
||||
["subtype"] = getItemSubtype,
|
||||
["subclassid"] = getItemSubclassId
|
||||
["subclassid"] = getItemSubclassId,
|
||||
["value"] = getItemValue
|
||||
}, function(slot, provided)
|
||||
---@cast provided { type: string, subtype: string, subclassid: number }
|
||||
if provided.type == "Consumable" and provided.subtype == "Other" and provided.subclassid == 8 then
|
||||
---@cast provided { type: string, subtype: string, subclassid: number, value: number }
|
||||
if provided.value == 0 and provided.type == "Consumable" and provided.subtype == "Other" and provided.subclassid == 8 then
|
||||
if debug then
|
||||
print(string.format("Artifact power filter pass for type %s and subtype %s and subclassid %d with value %d",
|
||||
provided.type, provided.subtype, provided.subclassid, provided.value))
|
||||
end
|
||||
return true
|
||||
end
|
||||
if debug then
|
||||
print(string.format("Artifact power filter fail for type %s and subtype %s and subclassid %d with value %d",
|
||||
provided.type, provided.subtype, provided.subclassid, provided.value))
|
||||
end
|
||||
return false
|
||||
end)
|
||||
|
||||
-- [09:19 AM] Dump: value=GetItemInfo("Elemental Pebbles")
|
||||
-- [09:19 AM] [1]="Elemental Pebbles",
|
||||
-- [09:19 AM] [2]="|cff9d9d9d|Hitem:132217::::::::110:72::::::|h[Elemental Pebbles]|h|r",
|
||||
-- [09:19 AM] [3]=0,
|
||||
-- [09:19 AM] [4]=100,
|
||||
-- [09:19 AM] [5]=1,
|
||||
-- [09:19 AM] [6]="Consumable",
|
||||
-- [09:19 AM] [7]="Other",
|
||||
-- [09:19 AM] [8]=20,
|
||||
-- [09:19 AM] [9]="",
|
||||
-- [09:19 AM] [10]=135234,
|
||||
-- [09:19 AM] [11]=27075,
|
||||
-- [09:19 AM] [12]=0,
|
||||
-- [09:19 AM] [13]=8,
|
||||
-- [09:19 AM] [14]=0,
|
||||
-- [09:19 AM] [15]=0,
|
||||
-- [09:19 AM] [17]=false
|
||||
|
||||
GetItemInfo("Brief History of the Ages")
|
||||
|
||||
-- [09:19 AM] Dump: value=GetItemInfo("Brief History of the Ages")
|
||||
-- [09:19 AM] [1]="Brief History of the Ages",
|
||||
-- [09:19 AM] [2]="|cffa335ee|Hitem:138782::::::::110:72::::::|h[Brief History of the Ages]|h|r",
|
||||
-- [09:19 AM] [3]=4,
|
||||
-- [09:19 AM] [4]=110,
|
||||
-- [09:19 AM] [5]=0,
|
||||
-- [09:19 AM] [6]="Consumable",
|
||||
-- [09:19 AM] [7]="Other",
|
||||
-- [09:19 AM] [8]=200,
|
||||
-- [09:19 AM] [9]="",
|
||||
-- [09:19 AM] [10]=134946,
|
||||
-- [09:19 AM] [11]=0,
|
||||
-- [09:19 AM] [12]=0,
|
||||
-- [09:19 AM] [13]=8,
|
||||
-- [09:19 AM] [14]=1,
|
||||
-- [09:19 AM] [15]=6,
|
||||
-- [09:19 AM] [17]=false
|
||||
|
||||
-- local azeriteFilter = {
|
||||
-- enabled = true,
|
||||
-- ilvlThreshold = 800,
|
||||
|
||||
Reference in New Issue
Block a user