thesonofdarwin

tunnel v1

Dec 31st, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. term.clear()
  2. term.setCursorPos(1, 1)
  3. print("Place Coal in Slot 1")
  4. print("Place at least 1 Cobblestone in Slot 2")
  5. print("Place Torches in Slot 3")
  6. print("Make tunnel length an even number.")
  7. print("")
  8. print("Enter tunnel length: ")
  9. tunnellength = read()
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. print("Tunneling  " .. tunnellength .. " blocks, then returning.")
  13. sleep(2)
  14.  
  15. local torchpos = 0
  16.  
  17. function fuelcheck()
  18. if turtle.getFuelLevel() < 150 then
  19. turtle.select(1)
  20. turtle.refuel(2)
  21. end
  22. end
  23.  
  24. function dropcobble()
  25. for i=4,16 do
  26. turtle.select(i)
  27. if turtle.compareTo(2) then
  28. turtle.drop()
  29. end
  30. end
  31. end
  32.  
  33. function minewallRight()
  34. turtle.dig()
  35. moveforward()
  36. turtle.digUp()
  37. turtle.digDown()
  38. turtle.turnRight()
  39. moveforward()
  40. turtle.digDown()
  41. turtle.digUp()
  42. moveforward()
  43. turtle.digDown()
  44. turtle.digUp()
  45. turtle.turnLeft()
  46. torchpos = torchpos + 1
  47. end
  48.  
  49. function minewallLeft()
  50. turtle.dig()
  51. moveforward()
  52. turtle.digUp()
  53. turtle.digDown()
  54. turtle.turnLeft()
  55. moveforward()
  56. turtle.digDown()
  57. turtle.digUp()
  58. moveforward()
  59. turtle.digDown()
  60. turtle.digUp()
  61. turtle.turnRight()
  62. torchpos = torchpos + 1
  63. end
  64.  
  65. function minecycle()
  66. for z = 1, tunnellength/2 do
  67. minewallRight()
  68. minewallLeft()
  69. placetorch()
  70. end
  71. end
  72.  
  73. function placetorch()
  74. if torchpos % 4 == 0 then
  75. turtle.select(3)
  76. turtle.turnLeft()
  77. turtle.dig()
  78. turtle.place()
  79. turtle.turnRight()
  80. dropcobble()
  81. fuelcheck()
  82. end
  83. end
  84.  
  85. function moveforward()
  86. while not turtle.forward() do
  87. turtle.dig()
  88. end
  89. end
  90.  
  91. function turtlehome()
  92. for y = 1, tunnellength do
  93. turtle.forward()
  94. end
  95. end
  96.  
  97. fuelcheck()
  98. turtle.digUp()
  99. turtle.up()
  100. minecycle()
  101. turtle.turnLeft()
  102. turtle.turnLeft()
  103. turtlehome()
  104. turtle.down()
  105. turtle.turnRight()
  106. turtle.turnRight()
  107. print("Mining Successful")
Advertisement
Add Comment
Please, Sign In to add comment