Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. -- Mining Program --
  2.  
  3. function intro(quit)
  4. -- intro function just reads input from player to lead to menu or the help doc --
  5. if quit then
  6. print("quitting")
  7. return
  8. else
  9. print("-------- Mining Program --------")
  10. print("--------------------------------")
  11. print("Press H for help or S for start")
  12. print("You can quit typing exit")
  13. print(" ")
  14. write("--> ")
  15. inputhelp = string.lower(read())
  16.  
  17. if inputhelp == "h" then
  18. playerhelp()
  19. elseif inputhelp == "exit" then
  20. print("quitting")
  21. elseif inputhelp == "s" then
  22. menu()
  23. else
  24. intro()
  25. end
  26. end
  27. end
  28.  
  29. function playerhelp()
  30. -- helpfunction --
  31.  
  32. print("HA, too bad")
  33. sleep(2)
  34. menu()
  35. end
  36.  
  37. function menu()
  38. --prints menu, shows settings --
  39.  
  40. term.clear()
  41. print("----------- Main Menu -----------")
  42. print("---------------------------------")
  43. print("--- Type in shortcuts like: T ---")
  44. print("--- Type exit for quitting ---")
  45. print(" ")
  46. write("Number corridors (-C) = ")
  47. write(corridors)
  48. print(" ")
  49. write("Length corridors (-L) = ")
  50. write(length)
  51. print(" ")
  52. write("Torches (-T) = ")
  53. write(torch)
  54. print(" ")
  55. write("Enderchest (-E) = ")
  56. write(ender)
  57. print(" ")
  58. write("Gap (-g) = ")
  59. write(gap)
  60. print(" ")
  61. write("--> ")
  62. playerinput = string.lower(read())
  63.  
  64. if playerinput == "c" then
  65. setcorridors()
  66. elseif playerinput == "l" then
  67. setlength()
  68. elseif playerinput == "t" then
  69. settorch()
  70. elseif playerinput == "e" then
  71. setender()
  72. elseif playerinput == "s" then
  73. mainfunction()
  74. elseif playerinput == "g" then
  75. setgap()
  76. elseif playerinput == "exit" then
  77. intro(1)
  78. else
  79. menu()
  80. end
  81. end
  82.  
  83. function setcorridors()
  84. write("-- set corridor number to? :")
  85. corridors = tonumber(read())
  86. menu()
  87. end
  88.  
  89. function setlength()
  90. write("-- set corridor length to? :")
  91. length = tonumber(read())
  92. menu()
  93. end
  94.  
  95. function settorch()
  96. write("-- Turn torches on or off? :")
  97. torch = read()
  98. menu()
  99. end
  100.  
  101. function setender()
  102. write("-- Turn Enderchest on or off?:")
  103. ender = read()
  104. menu()
  105. end
  106.  
  107. function setgap()
  108. write("-- set gap to?: ")
  109. gap = tonumber(read())
  110. menu()
  111. end
  112.  
  113. function mainfunction()
  114. i=0
  115. while i<corridors do
  116. t=0
  117. while t<length do
  118. digup()
  119. digforward()
  120. turtle.forward()
  121. safepath()
  122. if torch == "on" then
  123. checktorch()
  124. end
  125. if ender == "on" then
  126. checkender()
  127. end
  128. t = t+1
  129. end
  130.  
  131. turning()
  132. i = i+1
  133. end
  134. end
  135.  
  136. function turning()
  137. if turn == 0 then
  138. cleanleft()
  139. turtle.turnLeft()
  140. else
  141. cleanright()
  142. turtle.turnRight()
  143. end
  144. step = 0
  145. while step<gap do
  146. digup()
  147. digforward()
  148. turtle.forward()
  149. step=step+1
  150. end
  151. if turn == 0 then
  152. turtle.turnLeft()
  153. turn = 1
  154. else
  155. turtle.turnRight()
  156. turn = 0
  157. end
  158. end
  159.  
  160. function cleanleft()
  161. turtle.turnRight()
  162. step = 0
  163. while step<gap do
  164. digup()
  165. digforward()
  166. turtle.forward()
  167. step = step+1
  168. end
  169. turtle.turnRight()
  170. turtle.turnRight()
  171. for i=1,gap do
  172. turtle.forward()
  173. end
  174. end
  175.  
  176. function cleanright()
  177. turtle.turnLeft()
  178. step = 0
  179. while step<gap do
  180. digup()
  181. digforward()
  182. turtle.forward()
  183. step = step+1
  184. end
  185. turtle.turnLeft()
  186. turtle.turnLeft()
  187. for i=1,gap do
  188. turtle.forward()
  189. end
  190. end
  191.  
  192. function checkender()
  193. count = turtle.getItemCount(14)
  194. if count > 0 then
  195. emptyender()
  196. end
  197. end
  198.  
  199. function emptyender()
  200. turtle.digUp()
  201. turtle.select(1)
  202. turtle.Up()
  203. turtle.placeDown()
  204. s = 4
  205. repeat
  206. turtle.select(s)
  207. turtle.dropDown()
  208. s = s+1
  209. until s>15
  210. turtle.digDown()
  211. turtle.Down()
  212. turtle.select(3)
  213. turtle.placeDown()
  214. end
  215.  
  216.  
  217. function checktorch()
  218. if torches > 10 then
  219. turtle.turnLeft()
  220. turtle.turnLeft()
  221. turtle.select(2)
  222. turtle.place()
  223. turtle.turnLeft()
  224. turtle.turnLeft()
  225. torches = 0
  226. else
  227. torches = torches+1
  228. end
  229. end
  230.  
  231. function safepath()
  232. if turtle.detectDown() == false then
  233. select(3)
  234. turtle.placeDown()
  235. end
  236. end
  237.  
  238. function digup()
  239. while turtle.detectUp() do
  240. turtle.digUp()
  241. sleep(0.5)
  242. end
  243. end
  244.  
  245. function digforward()
  246. while turtle.detect() do
  247. turtle.dig()
  248. sleep(0.5)
  249. end
  250. end
  251.  
  252. inputs = {...} or {10,20,"On","Off","Off"}
  253. corridors = inputs[1] or 10
  254. length = inputs[2] or 20
  255. torch = inputs [3] or "On"
  256. ender = inputs [4] or "Off"
  257. start = inputs [5] or "Off"
  258. gap = 2
  259. torches = 0
  260. turn = 0
  261. if string.lower(start) == "on" then
  262. mainfunction()
  263. else
  264. intro()
  265. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement