subzero22

stripmine

Jan 6th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Stripmine 2.0
  2.  
  3. term.clear()
  4. term.setCursorPos(1,1)
  5. print("Stripmine 2.0 by subzero22")
  6. print("How long do you want the tunnels?")
  7. write("> ")
  8. x = tonumber( read() )
  9. print("How wide do you want each strip?")
  10. write("> ")
  11. w = tonumber( read() )
  12. print("How many strips do you want?")
  13. write("> ")
  14. r = tonumber( read() )
  15.  
  16. -- math to figure if strips is odd or even
  17. if r%2 == 1 then
  18. rm = "odd"
  19. else
  20. rm = "even"
  21. end
  22.  
  23. print("Would you like the turtle to make the strips left or right?")
  24. write("> ")
  25. left = string.lower(read())
  26.  
  27. print("Does the turtle have ender chest support? (yes/no)")
  28. print("If so put ender chest in slot 16")
  29. write("> ")
  30. ch = string.lower(read())
  31.  
  32. print("Would you like it to place torches? (yes/no)")
  33. print("If so put torches in slot 15")
  34. torch = string.lower(read())
  35.  
  36. if torch == "yes" then
  37. print("How many spaces do you want each torch to be?")
  38. ts = tonumber( read() )
  39. end
  40.  
  41. if torch == "yes" then
  42. tp = 14
  43. else
  44. tp = 15
  45. end
  46.  
  47. s = 1
  48. w = w + 1
  49. rw = w * r
  50. tl = 1
  51.  
  52. fuel = x * r + w * r + rw
  53. flvl = turtle.getFuelLevel()
  54. turtle.select(1)
  55.  
  56. while turtle.getFuelLevel() <= fuel do
  57. print("Turtle has "..flvl.." fuel and needs "..fuel.."fuel to strip this much.")
  58. print("Please put fuel in slot 1.")
  59. os.pullEvent("turtle_inventory")
  60. turtle.refuel(64)
  61. end
  62. print("Stripmine Starting")
  63. print("Turtle will use "..fuel.." fuel.")
  64. sleep(1)
  65.  
  66. function chest()
  67. if ch == "yes" then
  68. if turtle.getItemCount(tp) > 0 then
  69. turtle.select(16)
  70. if turtle.placeDown() == false then
  71. turtle.digDown()
  72. turtle.placeDown()
  73. end
  74. for i=1,tp do
  75. turtle.select(s)
  76. turtle.dropDown()
  77. s = s + 1
  78. end
  79. s = 1
  80. turtle.select(16)
  81. turtle.digDown()
  82. turtle.select(1)
  83. end
  84. turtle.select(1)
  85. end
  86. end
  87.  
  88. function strip()
  89.   chest()
  90.   while not turtle.forward() do
  91.     turtle.dig()
  92.     sleep(0.6)
  93.   end
  94.   while turtle.detectUp() do
  95.     turtle.digUp()
  96.     sleep(0.6)
  97.   end
  98.   while turtle.detectDown() do
  99.     turtle.digDown()
  100.   end
  101.   if torch == "yes" then
  102.     tl = tl + 1
  103.   end
  104.   if tl == ts then
  105.     turtle.select(15)
  106.     if turtle.getItemCount(15) < 0 then
  107.       print("Turtle is out of torches. Please place more in slot 14")
  108.       os.pullEvent("turtle_inventory")
  109.     else
  110.       turtle.select(15)
  111.       if turtle.placeDown() == false then
  112.         if turtle.placeUp() == false then
  113.           turtle.turnLeft()
  114.           turtle.turnLeft()
  115.           turtle.place()
  116.           turtle.turnLeft()
  117.           turtle.turnLeft()
  118.         end
  119.       end
  120.     end
  121.   turtle.select(1)
  122.   tl = 1
  123.   end
  124. end
  125.  
  126. function turn()
  127. if left == "left" then
  128. turtle.turnLeft()
  129. for i=1,w do
  130. strip()
  131. end
  132. turtle.turnLeft()
  133. left = "right"
  134. else
  135. turtle.turnRight()
  136. for i=1,w do
  137. strip()
  138. end
  139. turtle.turnRight()
  140. left = "left"
  141. end
  142. end
  143.  
  144. function back()
  145.   if rm == "odd" and left == "right" then
  146.     turtle.turnLeft()
  147.     for i=1,rw do
  148.       strip()
  149.     end
  150.       turtle.turnRight()
  151.     for i=1,x do
  152.       strip()
  153.     end
  154.   end
  155.   if rm == "odd" and left == "left" then
  156.     turtle.turnRight()
  157.     for i=1,rw do
  158.       strip()
  159.     end
  160.       turtle.turnLeft()
  161.     for i=1,x do
  162.         strip()
  163.     end
  164.   end
  165.   if rm == "even" and left == "left" then
  166.     turtle.turnRight()
  167.     for i=1,rw do
  168.       strip()
  169.     end
  170.   end
  171.   if rm == "even" and left == "right" then
  172.     turtle.turnLeft()
  173.     for i=1,rw do
  174.       strip()
  175.     end
  176.   end
  177. end
  178.  
  179.  
  180. for i=1,r do
  181. for i=1,x do
  182. strip()
  183. end
  184. turn()
  185. end
  186. back()
  187. print("Turtle has completed it's job.")
Advertisement
Add Comment
Please, Sign In to add comment