Guest User

stripmine2

a guest
Nov 15th, 2012
2,803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.47 KB | None | 0 0
  1. local tArgs = {...}
  2. print("Mining: "..tArgs[1].." spaces")
  3.  
  4. function StartFuel()
  5.  
  6. turtle.select(1)
  7. turtle.refuel(1)
  8. turtle.select(2)
  9. turtle.refuel(1)
  10. turtle.select(3)
  11. turtle.refuel(1)
  12. turtle.select(4)
  13. turtle.refuel(1)
  14. turtle.select(5)
  15. turtle.refuel(1)
  16. turtle.select(6)
  17. turtle.refuel(1)
  18. turtle.select(7)
  19. turtle.refuel(1)
  20. turtle.select(8)
  21. turtle.refuel(1)
  22. turtle.select(9)
  23. turtle.refuel(1)
  24. turtle.select(10)
  25. turtle.refuel(1)
  26. turtle.select(11)
  27. turtle.refuel(1)
  28. turtle.select(12)
  29. turtle.refuel(1)
  30. turtle.select(13)
  31. turtle.refuel(1)
  32. turtle.select(14)
  33. turtle.refuel(1)
  34. turtle.select(15)
  35. turtle.refuel(1)
  36. turtle.select(16)
  37. turtle.refuel(1)
  38. print("I consumed some coal to keep my fuel level up")
  39.  
  40. end
  41.  
  42.  
  43. function CheckItems()
  44. local item = 0
  45.  
  46. ea = turtle.getItemCount(1)
  47. eb = turtle.getItemCount(2)
  48. ec = turtle.getItemCount(3)
  49. ed = turtle.getItemCount(4)
  50. ee = turtle.getItemCount(5)
  51. ef = turtle.getItemCount(6)
  52. eg = turtle.getItemCount(7)
  53. eh = turtle.getItemCount(8)
  54. ei = turtle.getItemCount(9)
  55. ej = turtle.getItemCount(10)
  56. ek = turtle.getItemCount(11)
  57. el = turtle.getItemCount(12)
  58. em = turtle.getItemCount(13)
  59. en = turtle.getItemCount(14)
  60. eo = turtle.getItemCount(15)
  61. ep = turtle.getItemCount(16)
  62.  
  63. item = item+ea
  64. item = item+eb
  65. item = item+ec
  66. item = item+ed
  67. item = item+ee
  68. item = item+ef
  69. item = item+eg
  70. item = item+eh
  71. item = item+ei
  72. item = item+ej
  73. item = item+ek
  74. item = item+el
  75. item = item+em
  76. item = item+en
  77. item = item+eo
  78. item = item+ep
  79.  
  80. print("You have a total of this many items, in the turtle:")
  81. print(item)
  82. end
  83.  
  84. function CheckBlockUp()
  85.  
  86. while turtle.detectUp() == true do
  87. turtle.digUp()
  88. sleep(0.4)
  89. end
  90. end
  91.  
  92. function CheckFuel()
  93.  
  94. if turtle.getFuelLevel() == 30 then
  95. turtle.select(1)
  96. turtle.refuel(1)
  97. turtle.select(2)
  98. turtle.refuel(1)
  99. turtle.select(3)
  100. turtle.refuel(1)
  101. turtle.select(4)
  102. turtle.refuel(1)
  103. turtle.select(5)
  104. turtle.refuel(1)
  105. turtle.select(6)
  106. turtle.refuel(1)
  107. turtle.select(7)
  108. turtle.refuel(1)
  109. turtle.select(8)
  110. turtle.refuel(1)
  111. turtle.select(9)
  112. turtle.refuel(1)
  113. turtle.select(10)
  114. turtle.refuel(1)
  115. turtle.select(11)
  116. turtle.refuel(1)
  117. turtle.select(12)
  118. turtle.refuel(1)
  119. turtle.select(13)
  120. turtle.refuel(1)
  121. turtle.select(14)
  122. turtle.refuel(1)
  123. turtle.select(15)
  124. turtle.refuel(1)
  125. turtle.select(16)
  126. turtle.refuel(1)
  127. print("I consumed some coal to keep my fuel level up")
  128.  
  129. end
  130.  
  131. if turtle.getFuelLevel() == 5 then
  132. turtle.select(1)
  133. turtle.refuel(1)
  134. turtle.select(2)
  135. turtle.refuel(1)
  136. turtle.select(3)
  137. turtle.refuel(1)
  138. turtle.select(4)
  139. turtle.refuel(1)
  140. turtle.select(5)
  141. turtle.refuel(1)
  142. turtle.select(6)
  143. turtle.refuel(1)
  144. turtle.select(7)
  145. turtle.refuel(1)
  146. turtle.select(8)
  147. turtle.refuel(1)
  148. turtle.select(9)
  149. turtle.refuel(1)
  150. turtle.select(10)
  151. turtle.refuel(1)
  152. turtle.select(11)
  153. turtle.refuel(1)
  154. turtle.select(12)
  155. turtle.refuel(1)
  156. turtle.select(13)
  157. turtle.refuel(1)
  158. turtle.select(14)
  159. turtle.refuel(1)
  160. turtle.select(15)
  161. turtle.refuel(1)
  162. turtle.select(16)
  163. turtle.refuel(1)
  164. print("I consumed some coal to keep my fuel level up")
  165.  
  166. end
  167.  
  168. if turtle.getFuelLevel() == 0 then
  169. print("Shutting down...Reason: No fuel")
  170. sleep(20)
  171. shell.run("shutdown")
  172.  
  173. end
  174. end
  175.  
  176. function StopTorch()
  177.  
  178. if turtle.getItemCount(16) == 2 then
  179. print("Shutting down...Reason: Not enough torches")
  180. sleep(20)
  181. shell.run("shutdown")
  182.  
  183. end
  184. end
  185.  
  186. function attackMob()
  187.  
  188. sleep(0.1)
  189. turtle.attack()
  190. end
  191.  
  192. function forward2()
  193.  
  194. CheckFuel()
  195. checkBlock()
  196. CheckBlockUp()
  197. turtle.digUp()
  198. checkBlock()
  199. attackMob()
  200. turtle.dig()
  201. turtle.forward()
  202. attackMob()
  203.  
  204. end
  205.  
  206.  
  207. function checkBlock()
  208.  
  209. while turtle.detect() == true do
  210. turtle.dig()
  211. sleep(0.4)
  212. end
  213. end
  214.  
  215. function forward1()
  216. CheckBlockUp()
  217. checkBlock()
  218. checkBlock()
  219. CheckBlockUp()
  220. checkBlock()
  221. CheckBlockUp()
  222. attackMob()
  223. checkBlock()
  224. CheckBlockUp()
  225. CheckFuel()
  226. turtle.forward()
  227. attackMob()
  228. CheckFuel()
  229. turtle.down()
  230. CheckBlockUp()
  231. checkBlock()
  232. end
  233.  
  234. function forward()
  235. StopTorch()
  236. CheckFuel()
  237. checkBlock()
  238. CheckBlockUp()
  239. turtle.digUp()
  240. checkBlock()
  241. attackMob()
  242. turtle.dig()
  243. CheckBlockUp()
  244. CheckFuel()
  245. turtle.forward()
  246. CheckBlockUp()
  247.  
  248. attackMob()
  249.  
  250. end
  251.  
  252.  
  253. function mine()
  254.  
  255. forward1()
  256. forward()
  257. forward()
  258. CheckFuel()
  259. StopTorch()
  260. checkBlock()
  261. attackMob()
  262. CheckBlockUp()
  263. turtle.digUp()
  264. turtle.digDown()
  265. turtle.select(15)
  266. turtle.placeDown()
  267. CheckFuel()
  268. turtle.up()
  269. turtle.turnRight()
  270.  
  271. checkBlock()
  272. turtle.dig()
  273. checkBlock()
  274. turtle.digDown()
  275. CheckBlockUp()
  276. turtle.digUp()
  277. attackMob()
  278. CheckFuel()
  279. turtle.forward()
  280.  
  281. checkBlock()
  282. turtle.dig()
  283. checkBlock()
  284. turtle.digDown()
  285. CheckBlockUp()
  286. turtle.digUp()
  287. attackMob()
  288. CheckFuel()
  289. turtle.forward()
  290.  
  291. checkBlock()
  292. turtle.dig()
  293. checkBlock()
  294. turtle.digDown()
  295. CheckBlockUp()
  296. turtle.digUp()
  297. attackMob()
  298. CheckFuel()
  299. turtle.forward()
  300.  
  301. checkBlock()
  302. turtle.dig()
  303. checkBlock()
  304. turtle.digDown()
  305. CheckBlockUp()
  306. turtle.digUp()
  307. attackMob()
  308. CheckFuel()
  309. turtle.forward()
  310.  
  311. checkBlock()
  312. turtle.dig()
  313. checkBlock()
  314. turtle.digDown()
  315. CheckBlockUp()
  316. turtle.digUp()
  317. attackMob()
  318. CheckFuel()
  319. turtle.forward()
  320.  
  321. turtle.turnLeft()
  322. turtle.turnLeft()
  323. checkBlock()
  324. attackMob()
  325. CheckFuel()
  326. turtle.forward()
  327. checkBlock()
  328. CheckBlockUp()
  329. attackMob()
  330. CheckBlockUp()
  331. CheckFuel()
  332. turtle.forward()
  333. checkBlock()
  334. attackMob()
  335. CheckFuel()
  336. turtle.forward()
  337. CheckBlockUp()
  338. checkBlock()
  339. attackMob()
  340. CheckFuel()
  341. turtle.forward()
  342. CheckBlockUp()
  343. checkBlock()
  344. attackMob()
  345. CheckFuel()
  346. turtle.forward()
  347. CheckBlockUp()
  348. attackMob()
  349. checkBlock()
  350. turtle.dig()
  351. turtle.digDown()
  352. CheckBlockUp()
  353. turtle.digUp()
  354. attackMob()
  355. CheckFuel()
  356. turtle.forward()
  357.  
  358. checkBlock()
  359. turtle.dig()
  360. turtle.digDown()
  361. CheckBlockUp()
  362. turtle.digUp()
  363. attackMob()
  364. CheckFuel()
  365. turtle.forward()
  366.  
  367. checkBlock()
  368. turtle.dig()
  369. turtle.digDown()
  370. CheckBlockUp()
  371. turtle.digUp()
  372. attackMob()
  373. CheckFuel()
  374. turtle.forward()
  375.  
  376. checkBlock()
  377. turtle.dig()
  378. turtle.digDown()
  379. CheckBlockUp()
  380. turtle.digUp()
  381. attackMob()
  382. CheckFuel()
  383. turtle.forward()
  384.  
  385. checkBlock()
  386. turtle.dig()
  387. turtle.digDown()
  388. CheckBlockUp()
  389. turtle.digUp()
  390. attackMob()
  391. CheckFuel()
  392. turtle.forward()
  393.  
  394. turtle.turnRight()
  395. turtle.turnRight()
  396. checkBlock()
  397. attackMob()
  398. CheckFuel()
  399. turtle.forward()
  400. CheckBlockUp()
  401. checkBlock()
  402. attackMob()
  403. CheckFuel()
  404. turtle.forward()
  405. CheckBlockUp()
  406. checkBlock()
  407. attackMob()
  408. CheckFuel()
  409. turtle.forward()
  410. CheckBlockUp()
  411. checkBlock()
  412. attackMob()
  413. CheckFuel()
  414. turtle.forward()
  415. CheckBlockUp()
  416. checkBlock()
  417. attackMob()
  418. CheckFuel()
  419. turtle.forward()
  420. CheckBlockUp()
  421. attackMob()
  422. checkBlock()
  423. turtle.dig()
  424. turtle.digDown()
  425. CheckBlockUp()
  426. turtle.digUp()
  427. attackMob()
  428. checkBlock()
  429. turtle.turnLeft()
  430. StopTorch()
  431. CheckFuel()
  432. turtle.select(16)
  433. turtle.digDown()
  434. turtle.placeDown()
  435. CheckFuel()
  436. turtle.down()
  437. end
  438.  
  439. shell.run("clear")
  440. print("The Creator of this program is -Andersfc-")
  441. sleep(2)
  442. shell.run("clear")
  443. CheckItems()
  444. f = turtle.getFuelLevel()
  445. print("Your fuel level is:")
  446. print(f)
  447. z = turtle.getItemCount(16)
  448. print("You have this many items in slot #16:")
  449. print(z)
  450. print("Loading text...")
  451. sleep(10)
  452. shell.run("clear")
  453. print("Put torches in slot #16 to optionally place torches, or put an item/entity in the slot, so it wont place anything at all, put cobblestone or any desired block in slot #15 to make sure it places torches no matter what!")
  454. print("I use 27 fuel units, to move a cycle of a stripmine")
  455. print("Loading program...")
  456. sleep(20)
  457. print("Starting the stripmine...")
  458. StartFuel()
  459.  
  460. --Main Program:
  461.  
  462. --term.write("How many blocks to dig?")
  463. --blocks = read()
  464.  
  465. for i = 1, tArgs[1] do
  466. mine()
  467. end
Advertisement
Add Comment
Please, Sign In to add comment