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

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
+11 -1
View File
@@ -249,6 +249,16 @@ SlashCmdList["PROFCD"] = function(msg)
AA.Print("stored " .. key .. ": " .. (exp > 0 and (AA.FormatTime(exp - time()) .. " left") or "ready"))
end
AA.Print("file sync: " .. ((ImportFile and ExportFile) and "on" or "off"))
elseif cmd == "bags" then
for bag = 0, 10 do
local nm = GetBagName and GetBagName(bag)
local inv = ""
if bag >= 1 and bag <= 4 then inv = tostring(ContainerIDToInventoryID(bag))
elseif bag >= 5 and BankButtonIDToInvSlotID then inv = tostring(BankButtonIDToInvSlotID(bag - 4, 1)) end
local l = inv ~= "" and GetInventoryItemLink("player", tonumber(inv)) or nil
local _, _, ln = string.find(l or "", "%[(.-)%]")
AA.Print("bag " .. bag .. ": name=" .. tostring(nm) .. " slots=" .. tostring(GetContainerNumSlots(bag)) .. " invslot=" .. inv .. " link=" .. tostring(ln))
end
elseif cmd == "reset" then
for k in pairs(AA.me.cds) do AA.me.cds[k] = 0 end
AA.dirty = true
@@ -265,7 +275,7 @@ SlashCmdList["PROFCD"] = function(msg)
AA.Print("removed " .. n .. " character(s).")
AA.Refresh()
else
AA.Print("/ade - alts window | cd (cooldowns) | find <item> | list | sync | scan | status | debug | export | import | minimap | alert | reset | del <name>")
AA.Print("/ade - alts window | cd (cooldowns) | find <item> | list | sync | scan | status | debug | bags | export | import | minimap | alert | reset | del <name>")
end
end
+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
+34
View File
@@ -190,6 +190,37 @@ local function ReceiveEquip(text)
return true
end
-- bag sizes / used slots: B^name^realm^invBagsTs^bankBagsTs^inv^bank
local function EncodeBags(c)
return "B^" .. c.name .. "^" .. c.realm .. "^" .. (c.invBagsTs or 0) .. "^" .. (c.bankBagsTs or 0)
.. "^" .. (c.invBags or "") .. "^" .. (c.bankBags or "")
end
local function ReceiveBags(text)
local _, _, name, realm, its, bts, inv, bank =
string.find(text, "^B%^([^%^]*)%^([^%^]*)%^(%d*)%^(%d*)%^([^%^]*)%^(.*)$")
if not name or name == "" then return false end
local k = name .. "-" .. realm
local c = AA.db.chars[k]
if not c then
c = { name = name, realm = realm, cds = {}, remote = true }
AA.db.chars[k] = c
end
its, bts = tonumber(its) or 0, tonumber(bts) or 0
local ch = false
if its > (c.invBagsTs or 0) then
c.invBagsTs = its
c.invBags = inv
ch = true
end
if bts > (c.bankBagsTs or 0) then
c.bankBagsTs = bts
c.bankBags = bank
ch = true
end
return ch
end
local function FileRead(name)
if not (ImportFile and ExportFile) then return nil end
local ok, txt = pcall(ImportFile, name)
@@ -211,6 +242,8 @@ local function MergeText(txt)
if ReceiveProf(line) then n = n + 1 end
elseif t == "E^" then
if ReceiveEquip(line) then n = n + 1 end
elseif t == "B^" then
if ReceiveBags(line) then n = n + 1 end
elseif t == "I^" then
ReceiveItem(line)
end
@@ -245,6 +278,7 @@ local function FileWrite()
if c.prof then
for pname, p in pairs(c.prof) do table.insert(parts, EncodeProf(c, pname, p)) end
end
if c.invBags or c.bankBags then table.insert(parts, EncodeBags(c)) end
if c.equip then
table.insert(parts, EncodeEquip(c))
for slot, ref in pairs(c.equip) do