Bonzai1102

mine

Jan 4th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. function fuel()
  2. fuelLevel = turtle.getFuelLevel()
  3. if fuelLevel == "unlimited" or fuelLevel > 10 then
  4. return
  5. end
  6.  
  7. function tryRefuel()
  8. for n=1,16 do
  9. if turtle.getItemCount(n) > 0 then
  10. turtle.select(n)
  11. if turtle.refuel(1) then
  12. print("Fuel: "..turtle.getFuelLevel().."")
  13. turtle.select(1)
  14. return true
  15. end
  16. end
  17. end
  18. turtle.select(1)
  19. return false
  20. end
  21.  
  22. if not tryRefuel() then
  23. print( "Add more fuel to continue." )
  24. while not tryRefuel() do
  25. sleep(1)
  26. end
  27. print( "Resuming Tunnel." )
  28. end
  29. end
  30.  
  31. function turn()
  32. turtle.turnRight()
  33. turtle.turnRight()
  34. end
  35.  
  36. function dig()
  37. turtle.dig()
  38. sleep(1)
  39. end
  40.  
  41. function tunnel()
  42. distance = distance + 1
  43. turtle.digUp()
  44. turtle.select(1)
  45. turtle.placeDown()
  46. turtle.turnLeft()
  47. turtle.detect()
  48. turtle.place()
  49. turtle.turnLeft()
  50. turtle.turnLeft()
  51. turtle.detect()
  52. turtle.place()
  53. turtle.turnLeft()
  54. if distance == 9 then
  55. turtle.select(1)
  56. turtle.up()
  57. turtle.turnLeft()
  58. turtle.dig()
  59. sleep(1)
  60. while turtle.forward() == false do
  61. turtle.dig()
  62. sleep(1)
  63. end
  64. turtle.place()
  65. turtle.placeUp()
  66. turtle.back()
  67. turtle.select(16)
  68. turtle.place()
  69. turtle.turnRight()
  70. turtle.down()
  71. distance = 0
  72. end
  73. end
  74.  
  75. function back()
  76. turtle.up()
  77. turn()
  78. while j > 1 do
  79. if turtle.forward() == true then
  80. refuel()
  81. j = j - 1
  82. else
  83. dig()
  84. end
  85. end
  86. turtle.down()
  87. turn()
  88. end
  89.  
  90. -- Main-Script --
  91. write("Tunnel length: ")
  92. length = tonumber(read())
  93. print("Starting...")
  94. fuel()
  95. distance = 0
  96. i = 1
  97. j = 1
  98. while i <= length do
  99. if turtle.forward() == true then
  100. refuel()
  101. tunnel()
  102. i = i + 1
  103. j = j + 1
  104. else
  105. dig()
  106. end
  107. end
  108. back()
  109. print("Done...")
Advertisement
Add Comment
Please, Sign In to add comment