Fix small issues in loot and vendor

This commit is contained in:
M. David
2022-08-18 23:52:07 +02:00
parent 374515e222
commit d91242f99d
3 changed files with 23 additions and 40 deletions

View File

@@ -7,36 +7,7 @@ function(allstates, e)
for container = 0, 4 do
for slot = 1, GetContainerNumSlots(container) do
aura_env.filterService:run(container, slot)
local link = select(7, GetContainerItemInfo(container, slot))
if link then
local name = GetItemInfo(link)
local rarity = select(3, GetItemInfo(link))
local ilvl = select(4, GetItemInfo(link)) or 0
local type = select(6, GetItemInfo(link))
local price = select(11, GetItemInfo(link))
if price and price > 0 then
if aura_env.sellWhitelist[name] ~= 1 then
if rarity == 0 then
aura_env.toSell[#aura_env.toSell + 1] = {["container"] = container, ["slot"] = slot}
elseif (type == "Armor" or type == "Weapon") and ilvl < 350 then
aura_env.toSell[#aura_env.toSell + 1] = {["container"] = container, ["slot"] = slot}
end
end
end
end
end
end
aura_env.ticker = C_Timer.NewTicker(0.15, function()
if aura_env.toSell[1] then
UseContainerItem(aura_env.toSell[1].c, aura_env.toSell[1].s)
table.remove(aura_env.toSell, 1)
else
aura_env.ticker:Cancel()
end
if j >= GetContainerNumSlots(i) then i = i + 1
j = 1 end
if i >= 4 then aura_env.ticker:Cancel() end
end)
return true
end

View File

@@ -1,12 +1,11 @@
local debug = true
local debug = false
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)
return select(2, GetContainerItemInfo(container, slot))
end
local function getItemName(container, slot)
return select(1, GetItemInfo(getItemLink(container, slot)))
@@ -60,7 +59,16 @@ local gearFilter = {
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
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
@@ -69,13 +77,13 @@ local gearFilter = {
}
local function doSell(container, slot)
local itemIcon = getItemIcon(slot)
local itemName = getItemName(slot)
local itemQuantity = getItemQuantity(slot)
local itemQuality = getItemQuality(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 nameWithColor = aura_env.qualityColors[itemQuality + 1] .. "[" .. itemName .. "]\124r"
local nameWithQuantity = nameWithColor .. " x" .. itemQuantity
aura_env.debugLog("Assigning name" .. nameWithQuantity)
@@ -107,6 +115,10 @@ aura_env.filterService = {
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)

View File

@@ -46,7 +46,7 @@ local doLoot = function(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 nameWithColor = aura_env.qualityColors[itemQuality + 1] .. "[" .. itemName .. "]\124r"
local nameWithQuantity = nameWithColor .. " x" .. itemQuantity
aura_env.debugLog("Assigning name" .. nameWithQuantity)