Skip to content

Commit 2552d1e

Browse files
committed
Add search pattern to compare items against the character's max slot item level
1 parent a26c433 commit 2552d1e

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Search/CheckItem.lua

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,63 @@ local function AvgItemLevelPatternCheck(details, text)
16551655
end
16561656
end
16571657

1658+
local inventorySlotIlvl = {}
1659+
1660+
local function UpdateInventorySlotIlvl(details)
1661+
GetInvType(details)
1662+
1663+
if details.invType == "NONE" or GetItemLevel(details) == false then return end
1664+
1665+
local slot = inventorySlots[details.invType]
1666+
inventorySlotIlvl[slot] = max(inventorySlotIlvl[slot] or 0, details.itemLevel)
1667+
end
1668+
1669+
Syndicator.CallbackRegistry:RegisterCallback("BagCacheUpdate", function (_, character, data)
1670+
for i=0,1 do
1671+
local key = i == 0 and "bags" or "bank"
1672+
local inventory = SYNDICATOR_DATA.Characters[character][key]
1673+
for index in pairs(data[key]) do
1674+
local list = Syndicator.Search.GetBaseInfoFromList(inventory[index + 1])
1675+
for _, details in pairs(list) do UpdateInventorySlotIlvl(details) end
1676+
end
1677+
end
1678+
end)
1679+
1680+
Syndicator.CallbackRegistry:RegisterCallback("EquippedCacheUpdate", function(_, character)
1681+
local equipped = SYNDICATOR_DATA.Characters[character].equipped
1682+
local list = Syndicator.Search.GetBaseInfoFromList(equipped)
1683+
for _, details in pairs(list) do UpdateInventorySlotIlvl(details) end
1684+
end)
1685+
1686+
local function SlotItemLevelPatternCheck(details, text)
1687+
GetInvType(details)
1688+
1689+
if details.invType == "NONE" or GetItemLevel(details) == false then
1690+
return false
1691+
end
1692+
1693+
local op1, op2, diff = text:match("^([<>=]?)slotilvl([+-]?)(%d*)$")
1694+
local ilvl = details.itemLevel
1695+
local slot = inventorySlots[details.invType]
1696+
1697+
local slotilvl = inventorySlotIlvl[slot]
1698+
if not slotilvl then
1699+
return false
1700+
end
1701+
1702+
if tonumber(diff) then
1703+
slotilvl = slotilvl + tonumber(diff) * (op2 == "-" and -1 or 1)
1704+
end
1705+
1706+
if op1 == "<" then
1707+
return ilvl < slotilvl
1708+
elseif op1 == ">" then
1709+
return ilvl > slotilvl
1710+
else
1711+
return ilvl == slotilvl
1712+
end
1713+
end
1714+
16581715
local function GetAuctionValue(details)
16591716
if details.auctionValue then
16601717
return details.auctionValue >= 0
@@ -1714,6 +1771,7 @@ local patterns = {
17141771
["^[><=]?%d+$"] = ItemLevelPatternCheck,
17151772
["^%d+%-%d+$"] = ItemLevelRangePatternCheck,
17161773
["^[><=]?avgilvl[+-]?%d*$"] = AvgItemLevelPatternCheck,
1774+
["^[><=]?slotilvl[+-]?%d*$"] = SlotItemLevelPatternCheck,
17171775

17181776
["^[><=]?%d+[gsc]$"] = AHValuePatternCheck,
17191777
["^%d+[gsc]%-%d+[gsc]$"] = AHValueRangePatternCheck,

0 commit comments

Comments
 (0)