Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 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 chest = turtle.getItemCount(2) -- How many items are in slot 2 (chest)
  24. local ItemFuel = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel)
  25. local MD = 3 -- How Many Blocks Apart From Each Mine
  26. local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count
  27. local Fuel = 0 -- if 2 then it is unlimited no fuel needed
  28. local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0
  29. local Error = 0 -- 0 = No Error and 1 = Error
  30. local Way = 0 -- 0 = Left and 1 = Right
  31.  
  32. --Checking
  33. local function Check()
  34. if chest == 0 then
  35. print("there are no chests")
  36. Error = 1
  37. else
  38. print("There are chest in turtle")
  39. end
  40. if ItemFuel == 0 then
  41. print("No Fuel Items")
  42. error = 1
  43. else
  44. print("there is fuel")
  45. end
  46. repeat
  47. if turtle.getFuelLevel() == "unlimited" then
  48. print("NO NEED FOR FUEL")
  49. Needfuel = 0
  50. elseif turtle.getFuelLevel() < 100 then
  51. turtle.select(3)
  52. turtle.refuel(1)
  53. Needfuel = 1
  54. ItemFuel = ItemFuel - 1
  55. elseif NeedFuel == 1 then
  56. Needfuel = 0
  57. end
  58. until NeedFuel == 0
  59. end
  60.  
  61. -- Recheck if user forget something turtle will check after 15 sec
  62. local function Recheck()
  63. chest = turtle.getItemCount(2)
  64. ItemFuel = turtle.getItemCount(3)
  65. Error = 0
  66. end
  67.  
  68. --Mining
  69. local function ForwardM()
  70. repeat
  71. if turtle.detect() then
  72. turtle.dig()
  73. end
  74. if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  75. TF = TF - 1
  76. onlight = onlight + 1
  77. end
  78. if turtle.detectUp() then
  79. turtle.digUp()
  80. end
  81. turtle.select(4)
  82. turtle.placeDown()
  83. if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
  84. if chest > 0 then
  85. turtle.select(2)
  86. turtle.digDown()
  87. turtle.placeDown()
  88. chest = chest - 1
  89. for slot = 5, 16 do
  90. turtle.select(slot)
  91. turtle.dropDown()
  92. sleep(1.5)
  93. end
  94. turtle.select(5)
  95. else
  96. print("turtle run out of chest")
  97. os.shutdown()
  98. end
  99. end
  100. repeat
  101. if turtle.getFuelLevel() == "unlimited" then
  102. print("NO NEED FOR FUEL")
  103. Needfuel = 0
  104. elseif turtle.getFuelLevel() < 100 then
  105. turtle.select(3)
  106. turtle.refuel(1)
  107. Needfuel = 1
  108. ItemFuel = ItemFuel - 1
  109. elseif ItemFuel == 0 then
  110. print("turtle run out of fuel")
  111. os.shutdown()
  112. elseif NeedFuel == 1 then
  113. Needfuel = 0
  114. end
  115. until NeedFuel == 0
  116. until TF == 0
  117. end
  118.  
  119. --Warm Up For Back Program
  120. local function WarmUpForBackProgram() -- To make turn around so it can go back
  121. turtle.turnLeft()
  122. turtle.turnLeft()
  123. turtle.up()
  124. end
  125.  
  126. --Back Program
  127. local function Back()
  128. repeat
  129. if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  130. TB = TB - 1
  131. end
  132. if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
  133. if TB ~= 0 then
  134. turtle.dig()
  135. end
  136. end
  137. until TB == 0
  138. end
  139.  
  140. -- Multimines Program
  141. local function MultiMines()
  142. if Way == 1 then
  143. turtle.turnLeft()
  144. turtle.down()
  145. else
  146. turtle.turnRight()
  147. turtle.down()
  148. end
  149. repeat
  150. if turtle.detect() then
  151. turtle.dig()
  152. end
  153. if turtle.forward() then
  154. MD = MD - 1
  155. end
  156. if turtle.detectUp() then
  157. turtle.digUp()
  158. end
  159. until MD == 0
  160. if Way == 1 then
  161. turtle.turnLeft()
  162. else
  163. turtle.turnRight()
  164. end
  165. if MineTimes == 0 then
  166. print("Turtle is done")
  167. else
  168. MineTimes = MineTimes - 1
  169. end
  170. end
  171.  
  172. -- Restart
  173. local function Restart()
  174. TF = distance
  175. TB = distance
  176. MD = 3
  177. onlight = 0
  178. end
  179.  
  180. -- Starting
  181. function Start()
  182. repeat
  183. ForwardM()
  184. WarmUpForBackProgram()
  185. Back()
  186. MultiMines()
  187. Restart()
  188. until MineTimes == 0
  189. end
  190.  
  191. -- Start
  192. print("Hi There Welcome to Mining Turtle Program")
  193. print("How Far Will Turtle Go")
  194. input = io.read()
  195. distance = tonumber(input)
  196. TF = distance
  197. TB = distance
  198. print("Left or Right")
  199. print("0 = Left and 1 = Right")
  200. input2 = io.read()
  201. Way = tonumber(input2)
  202. print("How Many Times")
  203. input3 = io.read()
  204. MineTimes = tonumber(input3)
  205. Check()
  206. if Error == 1 then
  207. repeat
  208. sleep(10)
  209. Recheck()
  210. Check()
  211. until Error == 0
  212. end
  213. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement