Advertisement
sanovskiy

CSremover

Sep 27th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. function isBadBlock()
  2.     if not(turtle.detect()) then
  3.         return false
  4.     end
  5.     for slot=1,2,1 do
  6.         turtle.select(slot)
  7.         if turtle.compare() then
  8.             return true
  9.         end
  10.     end
  11.     return false
  12. end
  13.  
  14. function isBadBlockDown()
  15.     if not(turtle.detectDown()) then
  16.         return false
  17.     end
  18.     for slot=1,2,1 do
  19.         turtle.select(slot)
  20.         if turtle.compareDown() then
  21.             return true
  22.         end
  23.     end
  24.     return false
  25. end
  26.  
  27. function checkSides()
  28.     turtle.turnRight()
  29.     if isBadBlock() then
  30.         turtle.dig()
  31.     end
  32.     turtle.turnLeft()
  33.     if isBadBlock() then
  34.         turtle.dig()
  35.     end
  36.     turtle.turnLeft()
  37.     if isBadBlock() then
  38.         turtle.dig()
  39.     end
  40.     turtle.turnRight()
  41. end
  42.  
  43. function goForward()
  44.     while not(turtle.forward()) do
  45.         turtle.attack()
  46.     end
  47. end
  48. function goDown()
  49.     while not(turtle.down()) do
  50.         turtle.attackDown()
  51.     end
  52. end
  53. function goUp()
  54.     while not(turtle.up()) do
  55.         turtle.attackUp()
  56.     end
  57. end
  58.  
  59. function main()
  60.     curHeight = 0
  61.     while true do
  62.         checkSides()
  63.         while (not(turtle.detectDown()) or isBadBlockDown()) and (curHeight>-10) do
  64.             turtle.digDown()
  65.             goDown()
  66.             curHeight = curHeight-1
  67.             checkSides()
  68.         end
  69.         if not(turtle.detect()) or isBadBlock() then
  70.             turtle.dig()
  71.             goForward()
  72.         else
  73.             while turtle.detect() and not(isBadBlock()) do
  74.                 turtle.digUp()
  75.                 goUp()
  76.                 curHeight = curHeight+1
  77.             end
  78.             checkSides()
  79.             goForward()
  80.         end
  81.     end
  82. end
  83.  
  84. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement