Advertisement
Cavitt

Untitled

Feb 10th, 2012
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.31 KB | None | 0 0
  1. function depositItems(...)
  2.     bot(false) -- turn off walker/looter/targeter
  3.     local pos = directionPos(Self.Position(), Self.LookDirection()) -- get position of where we're looking
  4.     Self.UseItemFromGround(pos.x, pos.y, pos.z) -- open locker
  5.     wait(1500)
  6.     local locker = Container.GetByName("Locker")
  7.     print("DEBUG: started")
  8.     if(locker:isOpen()) then  -- did we open locker?
  9.         print("DEBUG: locker open")
  10.         locker:UseItem(0) -- open depot
  11.         wait(1500)
  12.         local depot = Container.GetByName("Depot Chest")
  13.         if(depot:isOpen()) then -- did we open depot?
  14.             print("DEBUG: depot open")
  15.             if(not tonumber(arg[1])) then
  16.                 print("DEBUG: using advanced method")
  17.                 for backpack, data in pairs(arg[1]) do -- loop through loot backpacks
  18.                     local bp = Container.GetByName(backpack)
  19.                     print("DEBUG: checking if " .. backpack.. " is open")
  20.                     if (bp:isOpen()) then -- loot backpack has to be open already
  21.                         print("DEBUG: " .. backpack.. " is open")
  22.                         local offset = 0
  23.                         for spot = 0, bp:ItemCount() do -- loop through all the items in loot backpack
  24.                             local item = bp:GetItemData(spot - offset)
  25.                             print("DEBUG: found item " .. item.id.. " in backpack")
  26.                             if (isInArray(data.items, item.id)) then -- the item is in the deposit list
  27.                                 print("DEBUG: the item is in list, trying to move")
  28.                                 bp:MoveItemToContainer(spot - offset, depot:Index(), data.depotSlot)
  29.                                 offset = offset + 1 -- we took an item out, the ones afterwards will shift back one
  30.                                 wait(600, 1500)
  31.                             end
  32.                         end
  33.                     end
  34.                 end
  35.             else
  36.                 print("DEBUG: using simple method, no debugging for this")
  37.                 local bp = Container.GetFirst()
  38.                 while (bp:isOpen()) do
  39.                     local name = bp:Name()
  40.                     if(name ~= "Locker") and (name ~= "Depot Chest") then
  41.                         local offset = 0
  42.                         for spot = 0, bp:ItemCount() do -- loop through all the items in loot backpack
  43.                             local item = bp:GetItemData(spot - offset)
  44.                             if (isInArray(arg, item.id)) then -- the item is in the deposit list
  45.                                 bp:MoveItemToContainer(spot - offset, depot:Index(), 0)
  46.                                 offset = offset + 1 -- we took an item out, the ones afterwards will shift back one
  47.                                 wait(600, 1500)
  48.                             end
  49.                         end
  50.                     end
  51.                     bp = bp:GetNext() -- next backpack
  52.                 end
  53.             end
  54.         end
  55.     end
  56.     bot(true)
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement