craniumkid22

CarlosIsLazy

Apr 20th, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rednet.open("right")
  2.  
  3. local function tryDigDown()
  4.     if turtle.digDown() then
  5.         return true
  6.     end
  7.     return false
  8. end
  9.  
  10. local function tryDown()
  11.     if turtle.down() then
  12.         print("Moving down")
  13.         return true
  14.     else
  15.         if tryDigDown() then
  16.             print("Moving down")
  17.             turtle.down()
  18.             return true
  19.         end
  20.     end
  21.     print("Can't dig down")
  22.     return false
  23. end
  24.  
  25. local function start()
  26.     x = 0
  27.     while tryDown() do
  28.         x = x + 1
  29.         print("Dug to level: "..x)
  30.     end
  31.     print("Cannot dig further. Bedrock likely reached")
  32.     print("Returning to surface")
  33.     while x > 0 do
  34.         if turtle.up() then
  35.             x = x - 1
  36.         else
  37.             sleep(1)
  38.         end
  39.     end
  40.     print("Setting the next position")
  41.     turtle.forward()
  42. end
  43.  
  44. local id, msg, dist = rednet.receive()
  45. if msg == "excavate" then
  46.     start()
  47. end
Advertisement
Add Comment
Please, Sign In to add comment