Skip to content

Commit 893c0c8

Browse files
committed
Add search pattern to compare items against the character's max slot item level
1 parent 95eafb3 commit 893c0c8

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
@@ -1589,6 +1589,63 @@ local function AvgItemLevelPatternCheck(details, text)
15891589
end
15901590
end
15911591

1592+
local inventorySlotIlvl = {}
1593+
1594+
local function UpdateInventorySlotIlvl(details)
1595+
GetInvType(details)
1596+
1597+
if details.invType == "NONE" or GetItemLevel(details) == false then return end
1598+
1599+
local slot = inventorySlots[details.invType]
1600+
inventorySlotIlvl[slot] = max(inventorySlotIlvl[slot] or 0, details.itemLevel)
1601+
end
1602+
1603+
Syndicator.CallbackRegistry:RegisterCallback("BagCacheUpdate", function (_, character, data)
1604+
for i=0,1 do
1605+
local key = i == 0 and "bags" or "bank"
1606+
local inventory = SYNDICATOR_DATA.Characters[character][key]
1607+
for index in pairs(data[key]) do
1608+
local list = Syndicator.Search.GetBaseInfoFromList(inventory[index + 1])
1609+
for _, details in pairs(list) do UpdateInventorySlotIlvl(details) end
1610+
end
1611+
end
1612+
end)
1613+
1614+
Syndicator.CallbackRegistry:RegisterCallback("EquippedCacheUpdate", function(_, character)
1615+
local equipped = SYNDICATOR_DATA.Characters[character].equipped
1616+
local list = Syndicator.Search.GetBaseInfoFromList(equipped)
1617+
for _, details in pairs(list) do UpdateInventorySlotIlvl(details) end
1618+
end)
1619+
1620+
local function SlotItemLevelPatternCheck(details, text)
1621+
GetInvType(details)
1622+
1623+
if details.invType == "NONE" or GetItemLevel(details) == false then
1624+
return false
1625+
end
1626+
1627+
local op1, op2, diff = text:match("^([<>=]?)slotilvl([+-]?)(%d*)$")
1628+
local ilvl = details.itemLevel
1629+
local slot = inventorySlots[details.invType]
1630+
1631+
local slotilvl = inventorySlotIlvl[slot]
1632+
if not slotilvl then
1633+
return false
1634+
end
1635+
1636+
if tonumber(diff) then
1637+
slotilvl = slotilvl + tonumber(diff) * (op2 == "-" and -1 or 1)
1638+
end
1639+
1640+
if op1 == "<" then
1641+
return ilvl < slotilvl
1642+
elseif op1 == ">" then
1643+
return ilvl > slotilvl
1644+
else
1645+
return ilvl == slotilvl
1646+
end
1647+
end
1648+
15921649
local function GetAuctionValue(details)
15931650
if details.auctionValue then
15941651
return details.auctionValue >= 0
@@ -1648,6 +1705,7 @@ local patterns = {
16481705
["^[><=]?%d+$"] = ItemLevelPatternCheck,
16491706
["^%d+%-%d+$"] = ItemLevelRangePatternCheck,
16501707
["^[><=]?avgilvl[+-]?%d*$"] = AvgItemLevelPatternCheck,
1708+
["^[><=]?slotilvl[+-]?%d*$"] = SlotItemLevelPatternCheck,
16511709

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

0 commit comments

Comments
 (0)