Advertisement
Guest User

cleanDown.lua

a guest
Jan 28th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. DIG = 0
  2. PLACE = 0
  3. MOVE = 0
  4.  
  5. function CleanTop()
  6.     turtle.turnLeft()
  7.     if Eval(turtle.inspect()) then
  8.         Replace()
  9.     end
  10.     turtle.turnRight()
  11.     turtle.turnRight()
  12.     if Eval(turtle.inspect()) then
  13.         Replace()
  14.     end
  15.     turtle.turnLeft()
  16.     if Eval(turtle.inspectDown()) then
  17.         ReplaceDown()
  18.     end
  19. end
  20.  
  21. function Eval(succ, block)
  22.     if block.name == "minecraft:stone" and block.metadata == 0 then
  23.         return false
  24.     elseif block.name == "minecraft:torch" then
  25.         return false
  26.     elseif block.name == "minecraft:birch_planks" then
  27.         return false
  28.     else
  29.         return true
  30.     end
  31. end
  32.  
  33. function Replace()
  34.     turtle.dig()
  35.     DIG = DIG + 1
  36.     turtle.select(1)
  37.     placed = turtle.place()
  38.     if not placed then
  39.         Replace()
  40.     end
  41.     PLACE = PLACE + 1
  42. end
  43.  
  44. function ReplaceUp()
  45.     turtle.digUp()
  46.     DIG = DIG + 1
  47.     turtle.select(1)
  48.     turtle.placeUp()
  49.     PLACE = PLACE + 1
  50. end
  51.  
  52. function ReplaceDown()
  53.         turtle.digDown()
  54.         DIG = DIG + 1
  55.         turtle.select(1)
  56.         turtle.placeDown()
  57.         PLACE = PLACE + 1
  58. end
  59.  
  60. function Run()
  61.     turtle.turnLeft()
  62.     turtle.turnLeft()
  63.     while not turtle.detect() do
  64.         turtle.forward()
  65.     end
  66. end
  67.  
  68. function SetStop()
  69.     turtle.select(2)
  70.     turtle.place()
  71. end
  72.  
  73. function Empty()
  74.     for block=3, 16 do
  75.         turtle.select(block)
  76.         turtle.drop()
  77.     end
  78. end
  79. Run()
  80. turtle.select(1)
  81. turtle.dig()
  82. while turtle.getItemCount() >= 3 and not turtle.detect() do
  83.     CleanTop()    
  84.     turtle.forward()
  85.     MOVE = MOVE + 1
  86. end
  87. SetStop()
  88. Run()
  89. Empty()
  90. print('Blocks Placed: ' .. PLACE)
  91. print('Moved: ' .. MOVE)
  92. print('Blocks Broken: ' .. DIG)
  93. print('Fuel: ' .. turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement