Advertisement
hucking

Untitled

Feb 20th, 2014
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ifContinue=true
  2. Detection=false
  3. turtle.select(1)
  4. Torch=false
  5. Islot=1
  6. print "Is the next turn left or right?"
  7. print "Type 1 for right, type 2 for left"
  8. Turn=io.read()
  9. function detectFunc()
  10.   if turtle.detect() then
  11.     turtle.select(16)
  12.     if turtle.compare() then
  13.       Detection=false
  14.       Torch=true
  15.     else
  16.       Detection=true
  17.    end
  18.    turtle.select(Islot)
  19.  else
  20.    Detection=false
  21.  end
  22. end
  23. function mainFunc()
  24.   if turtle.getItemCount(Islot)==1 then
  25.     if Islot>7 then
  26.       ifContinue=false
  27.       print "Out of blocks"
  28.     else
  29.       Islot=Islot+1
  30.       turtle.select(Islot)
  31.     end
  32.   else
  33.     detectFunc()
  34.     if Torch then
  35.       turtle.dig()
  36.       Torch=false
  37.     end
  38.     if Detection then
  39.       if turtle.detectDown() then
  40.         turtle.digDown()
  41.       end
  42.       turtle.placeDown()
  43.       if Turn==1 then
  44.         turtle.turnRight()
  45.         detectFunc()
  46.         if detection then
  47.           ifContinue=false
  48.           print "Blocked up ahead"
  49.         else
  50.           if Torch then
  51.             turtle.dig()
  52.             Torch=false
  53.           end
  54.           turtle.forward()
  55.           turtle.turnRight()
  56.           Turn=2
  57.         end
  58.       else
  59.         turtle.turnLeft()
  60.         detectFunc()
  61.         if detection then
  62.           ifContinue=false
  63.           print "Blocked up ahead"
  64.         else
  65.           if Torch then
  66.             turtle.dig()
  67.             Torch=false
  68.           end
  69.           turtle.forward()
  70.           turtle.turnLeft()
  71.           Turn=1
  72.         end
  73.       end
  74.     else
  75.       if turtle.detectDown() then
  76.         turtle.digDown()
  77.       end
  78.       turtle.placeDown()
  79.       turtle.forward()
  80.     end
  81.   end
  82. end
  83. ifContinue = true
  84. while ifContinue do
  85.   mainFunc()
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement