Загрузить файлы в «/»

This commit is contained in:
Ade
2026-10-14 02:33:00 +00:00
parent 9309da65ca
commit 82b9bf2e03
3 changed files with 104 additions and 4 deletions
+59 -3
View File
@@ -249,12 +249,16 @@ end
local function ScanContainers(bags)
local order, agg = {}, {}
local slotsTotal = 0
local binfo = {}
local claimed = {}
for _, bag in ipairs(bags) do
local slots = GetContainerNumSlots(bag) or 0
slotsTotal = slotsTotal + slots
local used = 0
for slot = 1, slots do
local link = GetContainerItemLink(bag, slot)
if link then
used = used + 1
local _, _, sid = string.find(link, "item:(%d+)")
local id = tonumber(sid)
if id then
@@ -270,6 +274,48 @@ local function ScanContainers(bags)
end
end
end
if slots > 0 then
-- the bag item itself (backpack / main bank have none)
local bid = 0
local inv
if bag >= 1 and bag <= 4 then
local ok, v = pcall(ContainerIDToInventoryID, bag)
if ok then inv = v end
elseif bag >= 5 and BankButtonIDToInvSlotID then
local ok, v = pcall(BankButtonIDToInvSlotID, bag - 4, 1)
if ok then inv = v end
end
-- the client's own bag name is authoritative; the inventory slot guess may point at another bag
local want = GetBagName and GetBagName(bag)
local function linkName(l)
local _, _, nm = string.find(l or "", "%[(.-)%]")
return nm
end
local pick, pickLink
if inv then
local l = GetInventoryItemLink("player", inv)
if l and not claimed[inv] and (not want or want == "" or linkName(l) == want) then pick, pickLink = inv, l end
end
if not pick and want and want ~= "" then
local lo, hi = 20, 23
if bag >= 5 then lo, hi = 40, 90 end
for s2 = lo, hi do
if not claimed[s2] then
local l = GetInventoryItemLink("player", s2)
if l and linkName(l) == want then pick, pickLink = s2, l; break end
end
end
end
if pick then
claimed[pick] = true
local _, _, bsid = string.find(pickLink, "item:(%d+)")
if bsid then
bid = tonumber(bsid)
LearnItem(bid, pickLink, GetInventoryItemTexture("player", pick))
end
end
table.insert(binfo, slots .. ":" .. used .. ":" .. bid)
end
end
if slotsTotal == 0 then return nil end
local list, parts = {}, {}
@@ -277,7 +323,7 @@ local function ScanContainers(bags)
table.insert(list, { id, agg[id] })
table.insert(parts, id .. ":" .. agg[id])
end
return list, table.concat(parts, "~")
return list, table.concat(parts, "~"), table.concat(binfo, "~")
end
-- equipped gear: slot -> "id:enchant:suffix:unique"
@@ -377,7 +423,12 @@ function AA.ScanSelf()
end
if ScanEquip() then changed = true end
if ScanSkills() then changed = true end
local list, sig = ScanContainers({ 0, 1, 2, 3, 4 })
local list, sig, binfo = ScanContainers({ 0, 1, 2, 3, 4 })
if list and binfo ~= AA.me.invBags then
AA.me.invBags = binfo
AA.me.invBagsTs = time()
changed = true
end
if list and sig ~= AA.me.invSig then
AA.me.inv = list
AA.me.invSig = sig
@@ -387,7 +438,12 @@ function AA.ScanSelf()
if AA.bankOpen then
local bags = { -1 }
for b = 5, 10 do table.insert(bags, b) end
local bl, bs = ScanContainers(bags)
local bl, bs, bbinfo = ScanContainers(bags)
if bl and bbinfo ~= AA.me.bankBags then
AA.me.bankBags = bbinfo
AA.me.bankBagsTs = time()
changed = true
end
if bl and bs ~= AA.me.bankSig then
AA.me.bank = bl
AA.me.bankSig = bs