Advertisement
Guest User

AJUWD_PAHYWD_PAWHD

a guest
Mar 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. -- This Version
  2. -- 2.13 10/11/2014
  3. -- ChangeLogs
  4. -- 2.04 - Adding Left or Right Support
  5. -- 2.05 - Changing Lot Code For Some Stable And Cleaner Code
  6. -- 2.06 - Ops Forget Fuel Chcking Code after rewrtitting
  7. -- 2.07 - Woops My Bad i wrote back() not Back()
  8. -- 2.08 - Fixing Imputs
  9. -- 2.09 - Forget That i change remove line of code since i use local function now
  10. -- 2.10 - Minor error with back that it leave one block in wall
  11. -- Change: Torch spacing to 8 from 10
  12. -- 2.11 - Change: Right to left and Left to Right better understand
  13. -- 2.12 - Add Stop Code when item are gone
  14. -- 2.13 - i made big mistake i forget to end to new stop code
  15. -- ToDoList
  16. -- Add Code to place torch each time it starts
  17. -- Add Fuel Code so can know almost how much fuel you need
  18. -- Add second fuel slot if you go allout diggin
  19. -- Mabye add code that make turtle make new line of tunnels
  20.  
  21. --Local
  22. local distance = 0 -- How Far Did User Pick
  23. local onlight = 0 -- When to Place Torch
  24. local depth = 0 -- How Deep
  25. local torch = turtle.getItemCount(1) -- How many items are in slot 1 (torch)
  26. local chest = turtle.getItemCount(2) -- How many items are in slot 2 (chest)
  27. local ItemFuel = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel)
  28. local MD = 3 -- How Many Blocks Apart From Each Mine
  29. local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count
  30. local Fuel = 0 -- if 2 then it is unlimited no fuel needed
  31. local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0
  32. local Error = 0 -- 0 = No Error and 1 = Error
  33. local Way = 0 -- 0 = Left and 1 = Right
  34.  
  35. --Checking
  36. local function Check()
  37. if torch == 0 then
  38. print("There are no torch's in Turtle")
  39. Error = 1
  40. else
  41. print("There are torch's in turtle")
  42. end
  43. if chest == 0 then
  44. print("there are no chests")
  45. Error = 1
  46. else
  47. print("There are chest in turtle")
  48. end
  49. if ItemFuel == 0 then
  50. print("No Fuel Items")
  51. error = 1
  52. else
  53. print("there is fuel")
  54. end
  55. repeat
  56. if turtle.getFuelLevel() == "unlimited" then
  57. print("NO NEED FOR FUEL")
  58. Needfuel = 0
  59. elseif turtle.getFuelLevel() < 100 then
  60. turtle.select(3)
  61. turtle.refuel(1)
  62. Needfuel = 1
  63. ItemFuel = ItemFuel - 1
  64. elseif NeedFuel == 1 then
  65. Needfuel = 0
  66. end
  67. until NeedFuel == 0
  68. end
  69.  
  70. -- Recheck if user forget something turtle will check after 15 sec
  71. local function Recheck()
  72. torch = turtle.getItemCount(1)
  73. chest = turtle.getItemCount(2)
  74. ItemFuel = turtle.getItemCount(3)
  75. Error = 0
  76. end
  77.  
  78. --Mining
  79. local function ForwardM()
  80. turtle.digDown()
  81. repeat
  82. if turtle.detect() then
  83. turtle.dig()
  84. end
  85. if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  86. TF = TF - 1
  87. onlight = onlight + 1
  88. end
  89. if turtle.detectUp() then
  90. turtle.digUp()
  91. end
  92. turtle.select(4)
  93. turtle.placeDown()
  94. if onlight == 8 then -- Every 10 Block turtle place torch
  95. if torch > 0 then
  96. turtle.turnLeft()
  97. turtle.turnLeft()
  98. turtle.select(1)
  99. turtle.place()
  100. turtle.turnLeft()
  101. turtle.turnLeft()
  102. torch = torch - 1
  103. onlight = onlight - 8
  104. else
  105. print("turtle run out of torchs")
  106. os.shutdown()
  107. end
  108. end
  109. if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
  110. if chest > 0 then
  111. turtle.select(2)
  112. turtle.digDown()
  113. turtle.placeDown()
  114. chest = chest - 1
  115. for slot = 5, 16 do
  116. turtle.select(slot)
  117. turtle.dropDown()
  118. sleep(1.5)
  119. end
  120. turtle.select(5)
  121. else
  122. print("turtle run out of chest")
  123. os.shutdown()
  124. end
  125. end
  126. repeat
  127. if turtle.getFuelLevel() == "unlimited" then
  128. print("NO NEED FOR FUEL")
  129. Needfuel = 0
  130. elseif turtle.getFuelLevel() < 100 then
  131. turtle.select(3)
  132. turtle.refuel(1)
  133. Needfuel = 1
  134. ItemFuel = ItemFuel - 1
  135. elseif ItemFuel == 0 then
  136. print("turtle run out of fuel")
  137. os.shutdown()
  138. elseif NeedFuel == 1 then
  139. Needfuel = 0
  140. end
  141. until NeedFuel == 0
  142. until TF == 0
  143. end
  144.  
  145. --Warm Up For Back Program
  146. local function WarmUpForBackProgram() -- To make turn around so it can go back
  147. turtle.turnLeft()
  148. turtle.turnLeft()
  149. turtle.up()
  150. end
  151.  
  152. --Back Program
  153. local function Back()
  154. turtle.digDown()
  155. repeat
  156. if turtle.detect() then
  157. turtle.dig()
  158. TB = TB - 1
  159. end
  160. if TB ~= 0 then
  161. turtle.turnRight()
  162. turtle.turnRight()
  163. end
  164. until TB == 0
  165. end
  166.  
  167. -- Multimines Program
  168. local function MultiMines()
  169. if Way == 1 then
  170. turtle.turnLeft()
  171. turtle.down()
  172. else
  173. turtle.turnRight()
  174. turtle.down()
  175. end
  176. repeat
  177. if turtle.detect() then
  178. turtle.dig()
  179. end
  180. if turtle.forward() then
  181. MD = MD - 1
  182. end
  183. if turtle.detectUp() then
  184. turtle.digUp()
  185. end
  186. until MD == 0
  187. if Way == 1 then
  188. turtle.turnLeft()
  189. else
  190. turtle.turnRight()
  191. end
  192. if depth == 0 then
  193. MineTimes = MineTimes - 1
  194. else
  195. depth = depth - 1
  196. end
  197. end
  198.  
  199. -- Restart
  200. local function Restart()
  201. TF = distance
  202. TB = distance
  203. MD = 3
  204. onlight = 0
  205. end
  206.  
  207. -- Starting
  208. function Start()
  209. repeat
  210. ForwardM()
  211. WarmUpForBackProgram()
  212. Back()
  213. MultiMines()
  214. Restart()
  215. until MineTimes == 0
  216. end
  217.  
  218. -- Start
  219. print("Hi There Welcome to Mining Turtle Program")
  220. print("How Far Will Turtle Go")
  221. input = io.read()
  222. distance = tonumber(input)
  223. TF = distance
  224. TB = distance
  225. print("Left or Right")
  226. print("0 = Left and 1 = Right")
  227. input2 = io.read()
  228. Way = tonumber(input2)
  229. print("How Many Times")
  230. input3 = io.read()
  231. MineTimes = tonumber(input3)
  232. print("How Deep to dig")
  233. input4 = io.read()
  234. depth = tonumber(input4)
  235. Check()
  236. if Error == 1 then
  237. repeat
  238. sleep(10)
  239. Recheck()
  240. Check()
  241. until Error == 0
  242. end
  243. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement