Advertisement
VADemon

Nether Traveller Turtle v1.5

Mar 24th, 2013
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. --Nether Traveller by VADemon
  2.  
  3. itemCount = turtle.getItemCount(1)
  4.  
  5. turtle.select(1)
  6.  
  7. function addCount()
  8.     itemCount = itemCount - 1
  9.     if itemCount == 0 then
  10.         for i = 2, 16 do
  11.             if turtle.getItemCount(1)==64 then
  12.                 itemCount = 64
  13.                 turtle.select(1)
  14.                 break
  15.             else
  16.                 turtle.select(i)
  17.                 turtle.transferTo(1, turtle.getItemSpace(1) )
  18.                 itemCount = turtle.getItemSpace(1)
  19.             end
  20.         end
  21.         -- if checked all slots, but <64 in total
  22.         print("I'm low on blocks!")
  23.         if itemCount == 0 then
  24.             print("No blocks left! Refill me please!")
  25.             print("Stopping!")
  26.             ready = true
  27.         end
  28.     end
  29. end
  30.  
  31. function goForward()
  32.     --sleep(1)
  33.     turtle.dig()
  34.    
  35.     if turtle.forward() then
  36.  
  37.         if not turtle.detectDown() then
  38.             if not turtle.placeDown() then
  39.                 print("Can't place a block, though there's nothing underneath!")
  40.                 print("Stopping!")
  41.                 ready = true
  42.             end
  43.             addCount()
  44.         end
  45.    
  46.     else
  47.         print("Something is on my way! Can't move.")
  48.         sleep(4)
  49.     end
  50. end
  51.  
  52. print("Press \"S\" to stop!")
  53.  
  54. local ready = false
  55. parallel.waitForAny(
  56.     function()
  57.         while not ready do
  58.             local event, key = os.pullEvent("key")
  59.             if key == 31 then
  60.                 ready = true
  61.                 print("Stopping...")
  62.             end
  63.         end    
  64.     end,
  65.     function()
  66.         while not ready do
  67.             goForward()
  68.         end
  69.     end
  70. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement