Advertisement
IMarvinTPA

Automatic Dropper

Dec 31st, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. --pastebin get 7BNdqE96 startup
  2.  
  3. local function isEmpty()
  4.     local bFull = true
  5.     local nTotalItems = 0
  6.     for n=1,16 do
  7.         local nCount = turtle.getItemCount(n)
  8.         if nCount == 0 then
  9.                 bFull = false
  10.         end
  11.         nTotalItems = nTotalItems + nCount
  12.     end
  13.          
  14.     if nCount == 0 then
  15.         print( "No more Items to drop." )
  16.         return true
  17.     end
  18.     return false
  19. end
  20.  
  21. local function unload()
  22.     print( "Unloading items..." )
  23.  
  24.     for n=1,16 do
  25.         --unloaded = unloaded + turtle.getItemCount(n)
  26.         if (turtle.getItemCount(n) > 0) then
  27.             turtle.select(n)
  28.             turtle.drop()
  29.             sleep(60)
  30.         end
  31.     end    
  32. end
  33.  
  34. local function load()
  35.  
  36.     print( "Loading items..." )
  37.  
  38.     for n=1,16 do
  39.         --unloaded = unloaded + turtle.getItemCount(n)
  40.         if (turtle.getItemCount(n) == 0) then
  41.             turtle.select(n)
  42.             res = turtle.suckUp()
  43.             if res == false then
  44.                 print( "No more Items to get." )
  45.                 return false
  46.             end
  47.             sleep(60)
  48.         end
  49.     end
  50.     return true
  51. end
  52.  
  53. print( "Dropping Down..." )
  54.  
  55.  
  56. while true do
  57.     if not isEmpty() then
  58.         --turtle.turnRight()
  59.         unload()
  60.         --turtle.turnLeft()
  61.     end
  62.     if not load() then
  63.         sleep(55)
  64.     end
  65.     sleep(5)
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement