lua code:function Self.DepositItems2(DPBox, ...)
if (#arg > 0) then setBotEnabled(false) end
local depositInfo = {}
function makeDepositInfo(input)
local ret = {}
for i = 1, #input do
local data = input[i]
local spot = 0
local id = 0
if (type(data) == 'table') then
spot = data[2]
id = Item.GetItemIDFromDualInput(data[1])
else
spot = 0
id = Item.GetItemIDFromDualInput(data)
end
if (not ret[spot]) then
ret[spot] = {}
ret[spot].realIndex = -1
ret[spot].items = {}
end
table.insert(ret[spot].items, id)
end
return ret
end
if (#arg > 0) then
depositInfo = makeDepositInfo(arg)
else
local _input = getDepositorList()
local _realInput = {}
for i = 1, #_input, 2 do
local tempInput = {}
tempInput[1] = _input[i]
tempInput[2] = _input[i+1]
table.insert(_realInput, tempInput)
end
depositInfo = makeDepositInfo(_realInput)
end
local indexes = Container.GetAll() -- list of containers open before we start depositing
local depot = Self.OpenDepot()
local badIndexes = #indexes == 0
if (badIndexes or not depot) then
if (badIndexes) then
print("XenoBot: Unable to find open backpacks to deposit from.")
else
print("XenoBot: Depositor failed to open depot.")
end
if (#arg > 0) then setBotEnabled(true) end
return false
end
depot:Minimize()
for i = 0, depot:ItemCount()-1 do
if (depot:GetItemData(i).id == 22796 + DPBox) then
depot:UseItem(i, true) wait(Self.Ping() * 2, Self.Ping() * 3)
end
end
for spot, data in pairs(depositInfo) do -- loop to open all the needed backpacks
local currentSpot = 0
for i = 0, depot:ItemCount() - 1 do -- search all items in the depot
if (Item.isContainer(depot:GetItemData(i).id)) then -- only consider containers
if (currentSpot == spot) then -- should we open this?
data.realIndex = Container.GetFreeSlot()
while (depot:UseItem(spot) ~= 1) do
wait(100)
end
wait(Self.Ping() + 300)
Container.Minimize(data.realIndex)
end
currentSpot = currentSpot + 1 -- increment
end
end
end
local tempDepositInfo = {} -- warn about and get rid of all depot backpacks which cant be opened
for spot, data in pairs(depositInfo) do
if (data.realIndex ~= -1) then
tempDepositInfo[spot] = data
else
print("XenoBot: Depositor is missing a container in depot slot #" .. spot .. ". Please place cascading containers at the required slot in your depot.")
end
end
depositInfo = tempDepositInfo
function depositItem(depositInfo, contFrom, spot) --when this returns true, we skip the item because we cant deposit it
local currentItem = contFrom:GetItemData(spot)
for _, data in pairs(depositInfo) do -- loop through all of our deposit items
if (table.contains(data.items, currentItem.id)) then -- should we deposit this specific one? try
local depositBp = Container.New(data.realIndex)
if (not depositBp:isOpen()) then -- dest container not open, skip this item
return true
end
if (depositBp:ItemCount() < depositBp:ItemCapacity()) then -- if the backpack isn't full, let's use the final slot
contFrom:MoveItemToContainer(spot, data.realIndex, depositBp:ItemCapacity() - 1)
return false
elseif (depositBp:ID() >= 22797 and depositBp:ID() <= 22813) then
contFrom:MoveItemToContainer(spot, data.realIndex, math.random(0, 3))
return false
else -- its full, lets either open the next one or find a good spot
local toSpot = -1 -- fine the best place to put it if we can still fit it
for sp = 0, depositBp:ItemCount() - 1 do
local spData = depositBp:GetItemData(sp)
if (spData.id == currentItem.id and spData.count ~= 100) then
toSpot = sp
end
end
if (not Item.isStackable(currentItem.id) or toSpot == -1) then -- no room for this, open a new container
if (not Item.isContainer(depositBp:GetItemData(depositBp:ItemCapacity() - 1).id)) then -- cant open this container, continue to the next item
if (not data.warned) then
data.warned = true
print("XenoBot: Depositor is unable to find room in deposit container #" .. data.realIndex .. ".")
end
return true
end
depositBp:UseItem(depositBp:ItemCapacity() - 1, true)
return false
else -- there's at least some room, lets fill it up
contFrom:MoveItemToContainer(spot, data.realIndex, toSpot)
return false
end
end
end
end
return true
end
function depositItems(depositInfo, indexes)
local containers = {}
for _, index in ipairs(indexes) do -- actually deposit now
local container = Container.New(index)
if (container:isOpen()) then
local checkSpot = 0
while (checkSpot < container:ItemCount()) do -- loop until no more items to deposit
if (depositItem(depositInfo, container, checkSpot)) then
checkSpot = checkSpot + 1 -- if we cant deposit this, skip it
else
if (containers[index] == nil) then containers[index] = 0 end
containers[index] = containers[index] + 1
wait(300, 700)
end
end
end
end
return containers
end
-- deposit items, cascading into new backpacks
local cascadedBps = {}
while (true) do
local cascades = depositItems(depositInfo, indexes)
wait(Self.Ping() + 200)
local opened = false
for index, count in pairs(cascades) do
if (count > 0) then
local cont = Container.New(index)
local lastItem = cont:GetItemData(cont:ItemCount() - 1)
if (Item.isContainer(lastItem.id)) then
if (cascadedBps[index] == nil) then cascadedBps[index] = 0 end
repeat
wait(Self.Ping() + 700)
until (cont:UseItem(cont:ItemCount() - 1, true) ~= 0)
wait(Self.Ping() + 700)
cascadedBps[index] = cascadedBps[index] + 1
opened = true
end
end
end
if (opened == false) then break end
end
-- go back to parent backpacks
for index, times in pairs(cascadedBps) do
for i = 1, times do
Container.GoBack(index)
wait(300, 700)
end
end
wait(800, 1300)
-- close everything
depot:Close()
wait(300, 600)
for spot, data in pairs(depositInfo) do
Container.New(data.realIndex):Close()
wait(200, 400)
end
wait(1500)
delayWalker(2500)
if (#arg > 0) then setBotEnabled(true) end
return true
end
Try this and tell me if it's working.