Advertisement
Guest User

sand

a guest
Jun 18th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. local checkPlacingBlocks = turtle.getItemCount(16)
  2.  
  3. function dig() -- Will dig the quicksand if detected
  4.     if turtle.detectDown() and turtle.digDown() then
  5.         sleep(0.5)
  6.     end
  7. end
  8.  
  9. function digLine() -- Will dig a line(3 blocks) of quicksand
  10.     for i = 1, 2 do
  11.         dig()
  12.         turtle.forward()
  13.     end
  14.     dig()
  15. end
  16.    
  17. function turnRight() -- Turns and moves the turtle
  18.     turtle.turnRight()
  19.     turtle.forward()
  20.     turtle.turnRight()
  21. end
  22.  
  23. function turnLeft() -- Turns and moves the turtle
  24.     turtle.turnLeft()
  25.     turtle.forward()
  26.     turtle.turnLeft()
  27. end
  28.  
  29. function digLayer() -- Will dig a layer(9 blocks) of quicksand
  30.     digLine()
  31.     turnRight()
  32.     digLine()
  33.     turnLeft()
  34.     digLine()
  35.     turtle.turnLeft()
  36.     turtle.turnLeft()
  37. end
  38.  
  39. function digAll() -- Will dig all(27 blocks) the quicksand
  40.     for i = 1, 2 do
  41.         digLayer()
  42.         turtle.down()
  43.     end
  44.     digLayer()
  45. end
  46.  
  47. function fillLine() -- Will fill a line(3 blocks) of quicksand
  48.     for i = 1, 2 do
  49.         turtle.placeDown()
  50.         turtle.forward()
  51.     end
  52.     turtle.placeDown()
  53. end
  54.  
  55. function fillLayer() -- Will fill a layer(9 blocks) of quicksand
  56.     fillLine()
  57.     turnRight()
  58.     fillLine()
  59.     turnLeft()
  60.     fillLine()
  61.     turtle.turnLeft()
  62.     turtle.turnLeft()
  63. end
  64.  
  65. function returnOrFill()
  66.     if checkPlacingBlocks > 26 then
  67.         print("Cleaning up the mess")
  68.         turtle.select(16)
  69.             for i = 1, 2 do
  70.                 fillLayer()
  71.                 turtle.up()
  72.             end
  73.         fillLayer()
  74.         turtle.select(1)
  75.     else
  76.         for i = 1, 2 do
  77.             turtle.up()
  78.             for i = 1, 2 do
  79.                 turtle.forward()
  80.             end
  81.         turtle.turnRight()
  82.         end
  83.     end
  84. end
  85.  
  86. -- Actual program
  87.  
  88. term.clear()
  89. term.setCursorPos(1, 1)
  90. print("Digging quicksand")
  91. turtle.select(1)
  92.  
  93. digAll()
  94. returnOrFill()
  95.  
  96. print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement