Advertisement
tknight98

ComputerCraft 3x3 mining turtle code

May 4th, 2020
1,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.79 KB | None | 0 0
  1. function initiate()
  2.     turtle.select(1)
  3.     turtle.refuel(3)
  4.     print("Please put 1 stack of coal in the first slot, 1 stack of cobble in the second slot, and 1 stack of torches in the third slot. Then start the program! ")
  5.     while turtle.detect()==false do
  6.         turtle.forward()
  7.     end
  8. end
  9.  
  10.  
  11. function CheckFuel()
  12.     if turtle.getFuelLevel() < 500 then
  13.         turtle.refuel(5)
  14.     end
  15. end
  16.  
  17.  
  18. function forward()
  19.     turtle.forward()
  20. end
  21.  
  22.  
  23. function dig()
  24.     turtle.dig()
  25. end
  26.  
  27.  
  28. function digup()
  29.     turtle.digUp()
  30. end
  31.  
  32.  
  33. function left()
  34.     turtle.turnLeft()
  35. end
  36.  
  37.  
  38. function right()
  39.     turtle.turnRight()
  40. end
  41.  
  42.  
  43. function up()
  44.     turtle.up()
  45. end
  46.  
  47.  
  48. function down()
  49.     turtle.down()
  50. end
  51.  
  52. function Hammer()
  53.     dig()
  54.     forward()
  55.     if turtle.detectDown()==false then
  56.         turtle.select(2)
  57.         turtle.placeDown()
  58.     end
  59.     turtle.turnLeft()
  60.     turtle.dig()
  61.     turtle.turnRight()
  62.     turtle.turnRight()
  63.     turtle.dig()
  64.     turtle.turnLeft()
  65.     turtle.digUp()
  66.     turtle.up()
  67.     turtle.turnLeft()
  68.     turtle.dig()
  69.     turtle.turnRight()
  70.     turtle.turnRight()
  71.     turtle.dig()
  72.     turtle.turnLeft()
  73.     turtle.digUp()
  74.     turtle.up()
  75.     turtle.turnLeft()
  76.     turtle.dig()
  77.     turtle.turnRight()
  78.     turtle.turnRight()
  79.     turtle.dig()
  80.     turtle.turnLeft()
  81.     turtle.down()
  82.     turtle.down()
  83. end
  84.  
  85.  
  86. function TorchHammer()
  87.     dig()
  88.     forward()
  89.     if turtle.detectDown()==false then
  90.         turtle.select(2)
  91.         turtle.placeDown()
  92.     end
  93.     left()
  94.     dig()
  95.     right()
  96.     right()
  97.     dig()
  98.     left()
  99.     digup()
  100.     up()
  101.     left()
  102.     dig()
  103.     right()
  104.     right()
  105.     dig()
  106.     left()
  107.     digup()
  108.     up()
  109.     left()
  110.     dig()
  111.     right()
  112.     right()
  113.     dig()
  114.     left()
  115.     down()
  116.     turtle.select(3)
  117.     turtle.placeDown()
  118.     turtle.dig()
  119.     turtle.forward()
  120.     turtle.digDown()
  121.     turtle.down()
  122.     if turtle.detectDown()==false then
  123.         turtle.select(2)
  124.         turtle.placeDown()
  125.     end
  126.     turtle.turnLeft()
  127.     turtle.dig()
  128.     turtle.turnRight()
  129.     turtle.turnRight()
  130.     turtle.dig()
  131.     turtle.turnLeft()
  132.     turtle.digUp()
  133.     turtle.up()
  134.     turtle.turnLeft()
  135.     turtle.dig()
  136.     turtle.turnRight()
  137.     turtle.turnRight()
  138.     turtle.dig()
  139.     turtle.turnLeft()
  140.     turtle.digUp()
  141.     turtle.up()
  142.     turtle.turnLeft()
  143.     turtle.dig()
  144.     turtle.turnRight()
  145.     turtle.turnRight()
  146.     turtle.dig()
  147.     turtle.turnLeft()
  148.     turtle.down()
  149.     turtle.down()
  150. end
  151.    
  152.  
  153. function excavation()
  154.     TorchHammer()
  155.     Hammer()
  156.     Hammer()
  157.     Hammer()
  158.     Hammer()
  159.     Hammer()
  160.     Hammer()
  161. end
  162.  
  163.  
  164.  
  165. function start()
  166.     initiate()
  167.     while true do
  168.         CheckFuel()
  169.         excavation()
  170.     end
  171. end
  172.  
  173. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement