Advertisement
Guest User

test7

a guest
Mar 1st, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.16 KB | None | 0 0
  1.  
  2. --Local
  3. local distance = 0 -- How Far Did User Pick
  4. local onlight = 0 -- When to Place Torch
  5. local torch = turtle.getItemCount(1) -- How many items are in slot 1 (torch)
  6. local chest = turtle.getItemCount(2) -- How many items are in slot 2 (chest)
  7. local ItemFuel = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel)
  8. local MD = 3 -- How Many Blocks Apart From Each Mine
  9. local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count
  10. local Fuel = 0 -- if 2 then it is unlimited no fuel needed
  11. local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0
  12. local Error = 0 -- 0 = No Error and 1 = Error
  13. local Way = 0 -- 0 = Left and 1 = Right
  14.  
  15. --Checking
  16. local function Check()
  17. if torch == 0 then
  18. print("There are no torch's in Turtle")
  19. Error = 1
  20. else
  21. print("There are torch's in turtle")
  22. end
  23. if chest == 0 then
  24. print("there are no chests")
  25. Error = 1
  26. else
  27. print("There are chest in turtle")
  28. end
  29. if ItemFuel == 0 then
  30. print("No Fuel Items")
  31. error = 1
  32. else
  33. print("there is fuel")
  34. end
  35. repeat
  36. if turtle.getFuelLevel() == "unlimited" then
  37. print("NO NEED FOR FUEL")
  38. Needfuel = 0
  39. elseif turtle.getFuelLevel() < 100 then
  40. turtle.select(3)
  41. turtle.refuel(1)
  42. Needfuel = 1
  43. ItemFuel = ItemFuel - 1
  44. elseif NeedFuel == 1 then
  45. Needfuel = 0
  46. end
  47. until NeedFuel == 00
  48. end
  49.  
  50. local function aboutFace()
  51.  
  52. turtle.turnLeft()
  53. turtle.turnLeft()
  54.  
  55. end
  56.  
  57. local function checkLava()
  58.  
  59. local success, data = turtle.inspect()
  60. if success then
  61. if data.name == "minecraft:flowing_lava" then
  62.  
  63. turtle.place()
  64. end
  65. end
  66. end
  67.  
  68. local function checkLavaAbove()
  69.  
  70. local success, data = turtle.inspectUp()
  71. if success then
  72. if data.name == "minecraft:flowing_lava" then
  73.  
  74. turtle.placeUp()
  75. end
  76. end
  77. end
  78.  
  79. -- Recheck if user forget something turtle will check after 15 sec
  80. local function Recheck()
  81. torch = turtle.getItemCount(1)
  82. chest = turtle.getItemCount(2)
  83. ItemFuel = turtle.getItemCount(3)
  84. Error = 0
  85. end
  86.  
  87. --Mining
  88. local function ForwardM()
  89. repeat
  90. if turtle.detect() then
  91. turtle.dig()
  92. end
  93. if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  94. TF = TF - 1
  95. onlight = onlight + 1
  96. end
  97. if turtle.detectUp then
  98.  
  99. turtle.digUp()
  100. end
  101.  
  102. turtle.select(4)
  103. turtle.placeDown() --turtle tunnels a 1x2 space; this will place a block down if none exists below, regardless
  104.  
  105. --newnew 3/1 -2
  106. turtle.turnRight()
  107.  
  108. checkLava() --check for lava and place down
  109. aboutFace() -- 180
  110. checkLava()
  111.  
  112. turtle.turnRight() --return turtle to original direction
  113.  
  114.  
  115. --new 3/1 - 1
  116. turtle.up()
  117.  
  118. turtle.turnRight()
  119.  
  120. checkLava()
  121. checkLavaAbove()
  122. aboutFace()
  123. checkLava()
  124.  
  125. turtle.turnRight()
  126.  
  127. turtle.down()
  128.  
  129. -- end new
  130.  
  131. if onlight == 8 then -- Every 10 Block turtle place torch
  132. if torch > 0 then
  133. aboutFace()
  134. turtle.select(1)
  135. turtle.place()
  136. aboutFace() --180 degree turn
  137. torch = torch - 1
  138. onlight = onlight - 8
  139. else
  140. print("turtle run out of torchs")
  141. os.shutdown()
  142. end
  143. end
  144. if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
  145. if chest > 0 then
  146. turtle.select(2)
  147. turtle.digDown()
  148. turtle.placeDown()
  149. chest = chest - 1
  150. for slot = 5, 16 do
  151. turtle.select(slot)
  152. turtle.dropDown()
  153. sleep(1.5)
  154. end
  155. turtle.select(5)
  156. else
  157. print("turtle run out of chest")
  158. os.shutdown()
  159. end
  160. end
  161. repeat
  162. if turtle.getFuelLevel() == "unlimited" then
  163. print("NO NEED FOR FUEL")
  164. Needfuel = 0
  165. elseif turtle.getFuelLevel() < 100 then
  166. turtle.select(3)
  167. turtle.refuel(1)
  168. Needfuel = 1
  169. ItemFuel = ItemFuel - 1
  170. elseif ItemFuel == 0 then
  171. print("turtle run out of fuel")
  172. os.shutdown()
  173. elseif NeedFuel == 1 then
  174. Needfuel = 0
  175. end
  176. until NeedFuel == 0
  177. until forwardProgress == stripLength
  178. end
  179.  
  180. local function deposit()
  181.  
  182. for slot = 5, 16 do --drops off
  183.  
  184. turtle.select(slot)
  185. turtle.dropDown()
  186. sleep(1.5)
  187. end
  188.  
  189. turtle.select(5) --prepares to load items again
  190.  
  191. end
  192.  
  193. local function NextStrip()
  194.  
  195. --get the turtle in place for next strip min
  196. --we start from chest orginal position
  197.  
  198. local distanceToStrip = stripProgress * MD
  199. repeat
  200. if turtle.forward() then
  201. distanceToStrip = distanceToStrip - 1
  202. end
  203. if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
  204. if distanceToStrip ~= 0 then
  205. turtle.dig()
  206. end
  207. end
  208. until distanceToStrip == 0
  209. turtle.turnLeft()
  210. end
  211.  
  212. local function ReturnToStrip()
  213.  
  214. aboutFace()
  215. turtle.up()
  216.  
  217.  
  218. repeat
  219. if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  220. returnProgress = returnProgress + 1
  221. end
  222. if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
  223. if returnProgress ~= stripLength then
  224. turtle.dig()
  225. end
  226. end
  227. until returnProgress == stripLength
  228. end
  229.  
  230. local function ReturnToChest()
  231.  
  232. local distanceToChest = stripProgress * MD
  233.  
  234. if distanceToChest == 0 then -- just
  235. deposit()
  236. end
  237.  
  238. turtle.turnRight()
  239. repeat
  240. if turtle.forward() then
  241. distanceToChest = distanceToChest - 1
  242. end
  243.  
  244. until distanceToChest == 0
  245. deposit()
  246. aboutFace()
  247.  
  248. end
  249.  
  250.  
  251. -- Restart
  252. local function Restart()
  253. forwardProgress = distance
  254. returnProgress = distance
  255. MD = 3
  256. onlight = 0
  257. end
  258.  
  259. -- Starting
  260. function Start()
  261. repeat
  262. ForwardM()
  263. ReturnToStrip()
  264.  
  265. turtle.down()
  266. ReturnToChest()
  267. NextStrip()
  268. Restart()
  269. until == 0
  270. end
  271.  
  272. -- Start
  273. print("Awesome mining program TWO")
  274. print("Ready to go?")
  275. os.pullEvent("key")
  276.  
  277. stripLength = 100
  278. forwardProgress = 0
  279. returnProgress = 0
  280.  
  281. Way = 1 --RIGHT
  282.  
  283. strips = 10
  284. stripProgress = 0
  285.  
  286. Check()
  287. if Error == 1 then
  288. repeat
  289. sleep(10)
  290. Recheck()
  291. Check()
  292. until Error == 0
  293. end
  294. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement