Quote:
if (labelName == "OpenToDeposit") then
Walker.Stop()
Self.CloseContainers() -- closes all backpacks
while (Dedi_WindowCount("all") < 3) do
Self.CloseContainers()
wait(500,600)
Self.OpenMainBackpack(true) -- Opening main backpack
wait(500,600)
Container.GetByName(MainBackpack):OpenChildren({St ackBackpack, true}) -- Opening backpack with stackable items
wait(500,600)
Container.GetByName(MainBackpack):OpenChildren({Lo otBackpack, true}) -- Opening backpack with items
Container:Minimize()
end
Walker.Start()
elseif (labelName == "Deposit") then
--Opening depot & bps
Walker.Stop()
findDepot()
wait(500,600)
Container.GetByName("Locker"):OpenChildren({3502, true}) -- Opens depot chest
wait(500,600)
Container.GetByName("Locker"):Close() -- Closes locker
wait(500,600)
Container.GetByName("Depot Chest"):OpenChildren({ItemsDepotBP, true}) -- Opens depot bp for normal items
wait(500,600)
Container.GetByName("Depot Chest"):OpenChildren({StackDepotBP, true}) -- Opens depot bp for stackables
wait(500,600)
while (Container.GetByName(ItemsDepotBP):isFull()) do -- Opening next backpack untill reach non fully filled
Dedi_OpenNextBp(ItemsDepotBP)
wait(200,400)
end
while (Container.GetByName(StackDepotBP):isFull()) do -- Opening next backpack untill reach non fully filled
Dedi_OpenNextBp(StackDepotBP)
wait(200,400)
end
--Depositing items
for i=0,5 do -- Repeat 4 times (put here amount of loot backpacks you have on yourself)
for j=Container.GetByName(LootBackpack):ItemCount()-1, 0, -1 do -- Checks all slot takens
local ItemName = Item.GetName(Container.GetByName(LootBackpack):Get ItemData(j).id):titlecase()
if table.contains(Items, ItemName) then -- If item is in Item list, move from loot backpack to depot bp)
Container.GetByName(LootBackpack):MoveItemToContai ner(j, Container.GetByName(ItemsDepotBP):Index(), Container.GetByName(ItemsDepotBP):ItemCapacity()-1)
wait(200,400)
end
if Container.GetByName(ItemsDepotBP):isFull() then -- If depot backpack is filled open next
Dedi_OpenNextBp(ItemsDepotBP)
wait(200,400)
end
end
Dedi_OpenNextBp(LootBackpack) -- Checked all slots in current loot backpack, so open next and repeat looking for items again :)
wait(200,400)
end
--Depositing stackables
-- Here we have only 1 backpack, so we don't have to repeat it few times
for j=Container.GetByName(StackBackpack):ItemCount()-1, 0, -1 do
local ItemName = Item.GetName(Container.GetByName(StackBackpack):Ge tItemData(j).id):titlecase()
if table.contains(Stackable, ItemName) then
Container.GetByName(StackBackpack):MoveItemToConta iner(j, Container.GetByName(StackDepotBP):Index(), Container.GetByName(StackDepotBP):ItemCapacity()-1)
wait(200,400)
end
if Container.GetByName(StackDepotBP):isFull() then
Dedi_OpenNextBp(StackDepotBP)
wait(200,400)
end
end
--Closing bps with items
Container.GetByName(ItemsDepotBP):Close()
wait(200,400)
Container.GetByName(StackDepotBP):Close()
wait(200,400)
-- Opening main backpack and backpack for supplies
Self.CloseContainers()
while Dedi_WindowCount("all") < 5 do
Self.CloseContainers()
wait(500,600)
Self.OpenMainBackpack(true)
wait(500,600)
Container.GetByName(MainBackpack):OpenChildren({Su pplyBackpack, true}, {LootBackpack, true}, {StackBackpack, true}, {FoodBackpack, true})
wait(500,600)
Container:Minimize()
end
Walker.Start()
end
end
and depositer function:
Quote:
-- Farmine Depots
local depots = {{33025, 31443,11},{33027, 31443,11},{33034, 31450,11},{33034, 31452,11},{33034, 31454,11},{33034, 31456,11},
{33019, 31451,11},{33019, 31453,11},{33019, 31455,11},{33019, 31449,11},{33030, 31462,11},{33028, 31462,11}}
-- Just a simple function that says if a position is on the screen or not
function onScreen(pos)
return (math.abs(Self.Position().x - pos.x) <= 7) and (math.abs(Self.Position().y - pos.y) <= 5)
end
-- Simple function that waits until your char isn't moving anymore
function waitUntilStill()
local pos = Self.Position()
repeat
pos = Self.Position()
wait(1000,1500)
until (Self.Position().x == pos.x) and (Self.Position().y == pos.y)
end
-- Calculates how many times you have to use the ground to get somewhere
function amountOfSteps(pos)
local dx = math.ceil(math.abs(Self.Position().x - pos.x)/6)
local dy = math.ceil(math.abs(Self.Position().y - pos.y)/4)
return math.max(dx,dy)
end
-- Function that makes your char "walk" somewhere using the ground.
function walkTo(pos)
local fromPos = Self.Position()
local toPos = pos
local tries = 0
local booly = false
repeat
if not onScreen(pos) then
local steps = amountOfSteps(pos)
for i = 1, steps do
toPos = {x = fromPos.x + math.ceil((pos.x - fromPos.x)*(i/steps)),
y = fromPos.y + math.ceil((pos.y - fromPos.y)*(i/steps)), z = pos.z}
if onScreen(toPos) then
Self.UseItemWithGround(3003, toPos.x, toPos.y, toPos.z)
waitUntilStill()
end
end
if onScreen(pos) then
booly = true
else
wait(2000)
print("Depot still not on the screen. Trying for the " .. tostring(tries) .. " time.")
end
else
booly = true
Self.UseItemWithGround(3003, toPos.x, toPos.y, toPos.z)
waitUntilStill()
end
tries = tries + 1
until booly or (tries > 3)
return booly
end
-- Randomly chooses a depot to go to
function findDepot()
local tries = 3
local booly = false
local reached = false
repeat
local maxi = #depots
-- Very random ;) not pseudo !
math.randomseed( os.time() )
math.random(); math.random(); math.random()
local i = math.random(maxi)
print("Trying to reach depot " .. tostring(i) .. ".")
local pos = {x = depots[i][1], y = depots[i][2], z = depots[i][3]}
if walkTo(pos) and (Self.LookPos().x == pos.x) and (Self.LookPos().y == pos.y) then
if Self.OpenDepot() then
booly = true
print("Depot reached and opened!")
else
print("Depot reached but could not open it.")
end
else
print("Depot cant be reached.")
gotoLabel("Start")
end
tries = tries + 1
until booly or (tries > 3)
return booly
end