Advertisement
Guest User

cleanUp.lua

a guest
Jan 28th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. DIG = 0
  2. MOVE = 0
  3. PLACE = 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.inspectUp()) then
  17.         ReplaceUp()
  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.     else
  27.         return true
  28.     end
  29. end
  30.  
  31. function Replace()
  32.     turtle.dig()
  33.     DIG = DIG + 1
  34.     turtle.select(1)
  35.     placed = turtle.place()
  36.     if not placed then
  37.         Replace()
  38.     end
  39.     PLACE = PLACE + 1
  40. end
  41.  
  42. function ReplaceUp()
  43.     turtle.digUp()
  44.     DIG = DIG + 1
  45.     turtle.select(1)
  46.     turtle.placeUp()
  47.     PLACE = PLACE + 1
  48. end
  49.  
  50. function ReplaceDown()
  51.     succ, block = turtle.inspect()
  52.     if block.name ~= "minecraft:birch_planks" then
  53.         turtle.digDown()
  54.         DIG = DIG + 1
  55.         turtle.select(1)
  56.         turtle.placeDown()
  57.         PLACE = PLACE + 1
  58.     end
  59. end
  60.  
  61. function Run()
  62.     turtle.turnLeft()
  63.     turtle.turnLeft()
  64.     while not turtle.detect() do
  65.         turtle.forward()
  66.     end
  67. end
  68.  
  69. function SetStop()
  70.     turtle.select(2)
  71.     turtle.place()
  72. end
  73.  
  74. function Empty()
  75.     for block=3, 16 do
  76.         turtle.select(block)
  77.         turtle.dropDown()
  78.     end
  79. end
  80.  
  81. function EvalComplete()
  82.     turtle.select(1)
  83.     if turtle.getItemCount() > 3 then
  84.         turtle.back()
  85.         turtle.down()
  86.     end
  87. end
  88.  
  89. Run()
  90. turtle.select(1)
  91. turtle.dig()
  92. while turtle.getItemCount() >= 3 and not turtle.detect() do
  93.     CleanTop()    
  94.     turtle.forward()
  95.     MOVE = MOVE + 1
  96. end
  97. SetStop()
  98. Run()
  99. Empty()
  100. print('Blocks Placed: ' .. PLACE)
  101. print('Moved: ' .. MOVE)
  102. print('Blocks Broken: ' .. DIG)
  103. print('Fuel: ' .. turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement