subzero22

Striptest

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