Xgamer911

16X16SteveFarm

Jul 18th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.92 KB | None | 0 0
  1. -- slots 2-4 164 dirt (64,64,36)
  2. -- slots 5-8 92 cobblestone (64,28)
  3. -- slot 9-11 tracks
  4. -- slot 12-13 empty
  5. -- slot 14 Dirt
  6. -- slot 15 Cobblestone
  7. -- slot 16 coal
  8.  
  9. local w,h = term.getSize()
  10. local selection = 0
  11. local internalselection = 0
  12. local range = 0
  13. local currentrange = 0
  14. local ypos = 1
  15. local fuel
  16. local fuelava
  17. local counter = 1
  18. local sandcounter=0
  19. local cobblecounter=0
  20. local rightnext = true
  21. local leftnext = true
  22. local rightcounter = 0
  23.  
  24. --Some draw functions to get us started
  25. local function printCentered(str, ypos)
  26. term.setCursorPos(w/2 - #str/2, ypos)
  27. term.write(str)
  28. end
  29.  
  30. local function printFarLeft(str, ypos)
  31. term.setCursorPos(1, ypos)
  32. term.write(str)
  33. end
  34.  
  35. local function printLeft(str, ypos)
  36. term.setCursorPos(5, ypos)
  37. term.write(str)
  38. end
  39.  
  40. local function printLeft2(str, ypos)
  41. term.setCursorPos(10, ypos)
  42. term.write(str)
  43. end
  44.  
  45. local function printRight(str, ypos)
  46. term.setCursorPos(w - 15, ypos)
  47. term.write(str)
  48. end
  49.  
  50. local function printRight2(str, ypos)
  51. term.setCursorPos(w - 25, ypos)
  52. term.write(str)
  53. end
  54.  
  55. local function printFarRight(str, ypos)
  56. term.setCursorPos(w - #str, ypos)
  57. term.write(str)
  58. end
  59.  
  60. function drawHeader()
  61. printCentered("Turtle Farm Builder", 1)
  62. printCentered(string.rep("-", w+1), 2)
  63.  
  64. -- print fuel level
  65. fuel = turtle.getFuelLevel()
  66. printFarLeft("Fuel " ,3)
  67. print(fuel)
  68.  
  69. -- print avilable fuel
  70. fuelava = turtle.getItemCount(16)
  71. printFarLeft("Fuel Available " ,5)
  72. print(fuelava)
  73.  
  74. -- print avilable fuel
  75. sandcounter = turtle.getItemCount(1) + turtle.getItemCount(2) + turtle.getItemCount(3) + turtle.getItemCount(4) + turtle.getItemCount(5) + turtle.getItemCount(6) + turtle.getItemCount(7) + turtle.getItemCount(8)
  76. printRight("Sand left "..tostring(sandcounter),3)
  77.  
  78. -- print avilable fuel
  79. cobblecounter = turtle.getItemCount(9) + turtle.getItemCount(10) + turtle.getItemCount(11) + turtle.getItemCount(12)
  80. printRight("Cobble left "..tostring(cobblecounter),4)
  81.  
  82. -- Print Range
  83. printRight("Range Left "..tostring(range),5)
  84. end
  85.  
  86. function drawMainMenu()
  87. printLeft2("1. Forward", 7)
  88. printRight("5. Up", 7)
  89.  
  90. printLeft2("2. Backward", 8)
  91. printRight("6. Down", 8)
  92.  
  93. printLeft2("3. Left", 9)
  94. printRight("7. Start Farm", 9)
  95.  
  96. printLeft2("4. Right", 10)
  97. printRight("8. Quit", 10)
  98.  
  99. printLeft2("Selection: ", 12)
  100. selection = tonumber(read())
  101. end
  102.  
  103. function forward()
  104. term.clear()
  105. term.setCursorPos(1,1)
  106. internalselection=0
  107. drawHeader()
  108.  
  109. printLeft("Forward", 7)
  110. printLeft("-------", 8)
  111. printLeft("1. Forward 1", 9)
  112. printRight("3. Main Menu", 9)
  113. printLeft("2. Forward range", 10)
  114.  
  115. printLeft("Selection: ", 12)
  116. internalselection = tonumber(read())
  117.  
  118. if internalselection==1 then
  119. turtle.forward()
  120. term.clear()
  121. term.setCursorPos(1,1)
  122. end
  123.  
  124. if internalselection==2 then
  125. term.clear()
  126. term.setCursorPos(1,1)
  127.  
  128. drawHeader()
  129.  
  130. printLeft("Forward Range", 7)
  131. printLeft("-------------", 8)
  132. printLeft("How far: ", 9)
  133. currentrange = 0
  134. range = tonumber(read())
  135.  
  136. repeat
  137. term.clear()
  138. term.setCursorPos(1,1)
  139. drawHeader()
  140.  
  141. turtle.forward()
  142. currentrange = currentrange + 1
  143. until currentrange == range
  144.  
  145. range=0
  146. end
  147. end
  148.  
  149. function backward()
  150. term.clear()
  151. term.setCursorPos(1,1)
  152. internalselection=0
  153. drawHeader()
  154.  
  155. printLeft("Backward", 7)
  156. printLeft("--------", 8)
  157. printLeft("1. Backward 1", 9)
  158. printRight("3. Main Menu", 9)
  159. printLeft("2. Backward range", 10)
  160.  
  161. printLeft("Selection: ", 12)
  162. internalselection = tonumber(read())
  163.  
  164. if internalselection==1 then
  165. turtle.back()
  166. term.clear()
  167. term.setCursorPos(1,1)
  168. end
  169.  
  170. if internalselection==2 then
  171. term.clear()
  172. term.setCursorPos(1,1)
  173.  
  174. drawHeader()
  175.  
  176. printLeft("Backward Range", 7)
  177. printLeft("-------------", 8)
  178. printLeft("How far: ", 9)
  179. currentrange = 0
  180. range = tonumber(read())
  181.  
  182. repeat
  183. term.clear()
  184. term.setCursorPos(1,1)
  185. drawHeader()
  186.  
  187. turtle.back()
  188. currentrange = currentrange + 1
  189. until currentrange == range
  190.  
  191. range=0
  192. end
  193.  
  194. if internalselection==3 then
  195. term.clear()
  196. term.setCursorPos(1,1)
  197. internalselection=0
  198. selection=0
  199. main()
  200. end
  201. end
  202.  
  203. function up()
  204. term.clear()
  205. term.setCursorPos(1,1)
  206. internalselection=0
  207. drawHeader()
  208.  
  209. printLeft("Up", 7)
  210. printLeft("--", 8)
  211. printLeft("1. Up 1", 9)
  212. printRight("3. Main Menu", 9)
  213. printLeft("2. Up range", 10)
  214.  
  215. printLeft("Selection: ", 12)
  216. internalselection = tonumber(read())
  217.  
  218. if internalselection==1 then
  219. turtle.up()
  220. term.clear()
  221. term.setCursorPos(1,1)
  222. end
  223.  
  224. if internalselection==2 then
  225. term.clear()
  226. term.setCursorPos(1,1)
  227.  
  228. drawHeader()
  229.  
  230. printLeft("Up Range", 7)
  231. printLeft("--------", 8)
  232. printLeft("How far: ", 9)
  233. currentrange = 0
  234. range = tonumber(read())
  235.  
  236. repeat
  237. term.clear()
  238. term.setCursorPos(1,1)
  239. drawHeader()
  240.  
  241. turtle.up()
  242. currentrange = currentrange + 1
  243. until currentrange == range
  244.  
  245. range=0
  246. end
  247.  
  248. if internalselection==3 then
  249. term.clear()
  250. term.setCursorPos(1,1)
  251. internalselection=0
  252. selection=0
  253. main()
  254. end
  255. end
  256.  
  257. function down()
  258. term.clear()
  259. term.setCursorPos(1,1)
  260. internalselection=0
  261. drawHeader()
  262.  
  263. printLeft("Down", 7)
  264. printLeft("----", 8)
  265. printLeft("1. Down 1", 9)
  266. printRight("3. Main Menu", 9)
  267. printLeft("2. Down range", 10)
  268.  
  269. printLeft("Selection: ", 12)
  270. internalselection = tonumber(read())
  271.  
  272. if internalselection==1 then
  273. turtle.down()
  274. term.clear()
  275. term.setCursorPos(1,1)
  276. end
  277.  
  278. if internalselection==2 then
  279. term.clear()
  280. term.setCursorPos(1,1)
  281.  
  282. drawHeader()
  283.  
  284. printLeft("Down Range", 7)
  285. printLeft("----------", 8)
  286. printLeft("How far: ", 9)
  287. currentrange = 0
  288. range = tonumber(read())
  289.  
  290. repeat
  291. term.clear()
  292. term.setCursorPos(1,1)
  293. drawHeader()
  294.  
  295. turtle.down()
  296. currentrange = currentrange + 1
  297. until currentrange == range
  298.  
  299. range=0
  300. end
  301.  
  302. if internalselection==3 then
  303. term.clear()
  304. term.setCursorPos(1,1)
  305. internalselection=0
  306. selection=0
  307. main()
  308. end
  309. end
  310.  
  311. function startfarm()
  312. term.clear()
  313. term.setCursorPos(1,1)
  314. internalselection=0
  315. drawHeader()
  316.  
  317. printLeft("Starting Farm", 7)
  318. printLeft("---------------", 8)
  319. printLeft("1. Clear Area", 9)
  320. printRight("3. Main Menu", 9)
  321. printLeft("2. Build Farm", 10)
  322.  
  323. printLeft("Selection: ", 12)
  324. internalselection = tonumber(read())
  325.  
  326. if internalselection==1 then
  327. counter = 0
  328. rightnext = true
  329. leftnext = false
  330.  
  331. while true do
  332. term.clear()
  333. term.setCursorPos(1,1)
  334. drawHeader()
  335. Refuel()
  336.  
  337. turtle.select(1)
  338. if turtle.detect() then
  339. turtle.dig()
  340. end
  341. if turtle.detectUp() then
  342. turtle.digUp()
  343. end
  344.  
  345. if turtle.detectDown() then
  346. turtle.digDown()
  347. turtle.select(1)
  348. turtle.placeDown()
  349. counter = counter + 1
  350. else
  351. turtle.select(1)
  352. turtle.placeDown()
  353. counter = counter + 1
  354. end
  355.  
  356. if counter<16 then
  357. turtle.forward()
  358. end
  359.  
  360. if rightcounter==8 then
  361. if counter==16 then
  362. turtle.turnRight()
  363. for i = 1, 15, 1 do
  364. turtle.forward()
  365. end
  366. turtle.turnRight()
  367. break
  368. end
  369. end
  370.  
  371. if counter==16 then
  372. if rightnext==true then
  373. turtle.turnRight()
  374. turtle.dig()
  375. turtle.forward()
  376. turtle.turnRight()
  377. counter = 0
  378. rightcounter = rightcounter+1
  379. rightnext = false
  380. leftnext = true
  381. elseif leftnext==true then
  382. turtle.turnLeft()
  383. turtle.dig()
  384. turtle.forward()
  385. turtle.turnLeft()
  386. counter = 0
  387. rightnext = true
  388. leftnext = left
  389. end
  390. end
  391.  
  392. term.clear()
  393. term.setCursorPos(1,1)
  394. end
  395. end
  396.  
  397. if internalselection==2 then
  398.  
  399. turtle.turnRight()
  400. turtle.forward()
  401. turtle.turnLeft()
  402. turtle.forward()
  403.  
  404. term.clear()
  405. term.setCursorPos(1,1)
  406. drawHeader()
  407. Refuel()
  408.  
  409. --LAYING DOWN COBBLESTONE
  410. drawHeader()
  411. Refuel()
  412. for i = 1, 13, 1 do
  413. turtle.digDown()
  414. turtle.select(5)
  415. turtle.placeDown()
  416. if turtle.detect() then
  417. turtle.dig()
  418. end
  419. if turtle.detectUp() then
  420. turtle.digUp()
  421. end
  422. turtle.forward()
  423. end
  424. turtle.turnRight()
  425. for i = 1, 3, 1 do
  426. turtle.digDown()
  427. turtle.select(5)
  428. turtle.placeDown()
  429. if turtle.detect() then
  430. turtle.dig()
  431. end
  432. if turtle.detectUp() then
  433. turtle.digUp()
  434. end
  435. turtle.forward()
  436. end
  437. turtle.turnRight()
  438. drawHeader()
  439. Refuel()
  440. for i = 1, 10, 1 do
  441. turtle.digDown()
  442. turtle.select(5)
  443. turtle.placeDown()
  444. if turtle.detect() then
  445. turtle.dig()
  446. end
  447. if turtle.detectUp() then
  448. turtle.digUp()
  449. end
  450. turtle.forward()
  451. end
  452. turtle.turnLeft()
  453. for i = 1, 2, 1 do
  454. turtle.digDown()
  455. turtle.select(5)
  456. turtle.placeDown()
  457. if turtle.detect() then
  458. turtle.dig()
  459. end
  460. if turtle.detectUp() then
  461. turtle.digUp()
  462. end
  463. turtle.forward()
  464. end
  465. turtle.turnLeft()
  466. drawHeader()
  467. Refuel()
  468. for i = 1, 10, 1 do
  469. turtle.digDown()
  470. turtle.select(5)
  471. turtle.placeDown()
  472. if turtle.detect() then
  473. turtle.dig()
  474. end
  475. if turtle.detectUp() then
  476. turtle.digUp()
  477. end
  478. turtle.forward()
  479. end
  480. turtle.turnRight()
  481. for i = 1, 3, 1 do
  482. turtle.digDown()
  483. turtle.select(5)
  484. turtle.placeDown()
  485. if turtle.detect() then
  486. turtle.dig()
  487. end
  488. if turtle.detectUp() then
  489. turtle.digUp()
  490. end
  491. turtle.forward()
  492. end
  493. turtle.turnRight()
  494. drawHeader()
  495. Refuel()
  496. for i = 1, 10, 1 do
  497. turtle.digDown()
  498. turtle.select(5)
  499. turtle.placeDown()
  500. if turtle.detect() then
  501. turtle.dig()
  502. end
  503. if turtle.detectUp() then
  504. turtle.digUp()
  505. end
  506. turtle.forward()
  507. end
  508. turtle.turnLeft()
  509. for i = 1, 2, 1 do
  510. turtle.digDown()
  511. turtle.select(5)
  512. turtle.placeDown()
  513. if turtle.detect() then
  514. turtle.dig()
  515. end
  516. if turtle.detectUp() then
  517. turtle.digUp()
  518. end
  519. turtle.forward()
  520. end
  521. turtle.turnLeft()
  522. drawHeader()
  523. Refuel()
  524. for i = 1, 10, 1 do
  525. turtle.digDown()
  526. turtle.select(5)
  527. turtle.placeDown()
  528. if turtle.detect() then
  529. turtle.dig()
  530. end
  531. if turtle.detectUp() then
  532. turtle.digUp()
  533. end
  534. turtle.forward()
  535. end
  536. turtle.turnRight()
  537. for i = 1, 3, 1 do
  538. turtle.digDown()
  539. turtle.select(5)
  540. turtle.placeDown()
  541. if turtle.detect() then
  542. turtle.dig()
  543. end
  544. if turtle.detectUp() then
  545. turtle.digUp()
  546. end
  547. turtle.forward()
  548. end
  549. Refuel()
  550. drawHeader()
  551. turtle.turnRight()
  552. for i = 1, 13, 1 do
  553. turtle.digDown()
  554. turtle.select(5)
  555. turtle.placeDown()
  556. if turtle.detect() then
  557. turtle.dig()
  558. end
  559. if turtle.detectUp() then
  560. turtle.digUp()
  561. end
  562. turtle.forward()
  563. end
  564. turtle.turnRight()
  565. drawHeader()
  566. Refuel()
  567. for i = 1, 13, 1 do
  568. turtle.digDown()
  569. turtle.select(5)
  570. turtle.placeDown()
  571. if turtle.detect() then
  572. turtle.dig()
  573. end
  574. if turtle.detectUp() then
  575. turtle.digUp()
  576. end
  577. turtle.forward()
  578. end
  579. turtle.turnRight()
  580. --END LAYING COBBLESTONE
  581. --***********************************************
  582. --Start laying track
  583. turtle.up()
  584. drawHeader()
  585. Refuel()
  586. for i = 1, 13, 1 do
  587. turtle.select(9)
  588. turtle.placeDown()
  589. if turtle.detect() then
  590. turtle.dig()
  591. end
  592. if turtle.detectUp() then
  593. turtle.digUp()
  594. end
  595. turtle.forward()
  596. end
  597. turtle.turnRight()
  598. drawHeader()
  599. Refuel()
  600. for i = 1, 3, 1 do
  601. turtle.select(9)
  602. turtle.placeDown()
  603. if turtle.detect() then
  604. turtle.dig()
  605. end
  606. if turtle.detectUp() then
  607. turtle.digUp()
  608. end
  609. turtle.forward()
  610. end
  611. turtle.turnRight()
  612. drawHeader()
  613. Refuel()
  614. for i = 1, 10, 1 do
  615. turtle.select(9)
  616. turtle.placeDown()
  617. if turtle.detect() then
  618. turtle.dig()
  619. end
  620. if turtle.detectUp() then
  621. turtle.digUp()
  622. end
  623. turtle.forward()
  624. end
  625. turtle.turnLeft()
  626. drawHeader()
  627. Refuel()
  628. for i = 1, 2, 1 do
  629. turtle.select(9)
  630. turtle.placeDown()
  631. if turtle.detect() then
  632. turtle.dig()
  633. end
  634. if turtle.detectUp() then
  635. turtle.digUp()
  636. end
  637. turtle.forward()
  638. end
  639. turtle.turnLeft()
  640. drawHeader()
  641. Refuel()
  642. for i = 1, 10, 1 do
  643. turtle.select(9)
  644. turtle.placeDown()
  645. if turtle.detect() then
  646. turtle.dig()
  647. end
  648. if turtle.detectUp() then
  649. turtle.digUp()
  650. end
  651. turtle.forward()
  652. end
  653. turtle.turnRight()
  654. drawHeader()
  655. Refuel()
  656. for i = 1, 3, 1 do
  657. turtle.select(9)
  658. turtle.placeDown()
  659. if turtle.detect() then
  660. turtle.dig()
  661. end
  662. if turtle.detectUp() then
  663. turtle.digUp()
  664. end
  665. turtle.forward()
  666. end
  667. turtle.turnRight()
  668. drawHeader()
  669. Refuel()
  670. for i = 1, 10, 1 do
  671. turtle.select(9)
  672. turtle.placeDown()
  673. if turtle.detect() then
  674. turtle.dig()
  675. end
  676. if turtle.detectUp() then
  677. turtle.digUp()
  678. end
  679. turtle.forward()
  680. end
  681. turtle.turnLeft()
  682. drawHeader()
  683. Refuel()
  684. for i = 1, 2, 1 do
  685. turtle.select(9)
  686. turtle.placeDown()
  687. if turtle.detect() then
  688. turtle.dig()
  689. end
  690. if turtle.detectUp() then
  691. turtle.digUp()
  692. end
  693. turtle.forward()
  694. end
  695. turtle.turnLeft()
  696. drawHeader()
  697. Refuel()
  698. for i = 1, 10, 1 do
  699. turtle.select(9)
  700. turtle.placeDown()
  701. if turtle.detect() then
  702. turtle.dig()
  703. end
  704. if turtle.detectUp() then
  705. turtle.digUp()
  706. end
  707. turtle.forward()
  708. end
  709. turtle.turnRight()
  710. drawHeader()
  711. Refuel()
  712. for i = 1, 3, 1 do
  713. turtle.select(9)
  714. turtle.placeDown()
  715. if turtle.detect() then
  716. turtle.dig()
  717. end
  718. if turtle.detectUp() then
  719. turtle.digUp()
  720. end
  721. turtle.forward()
  722. end
  723. turtle.turnRight()
  724. drawHeader()
  725. Refuel()
  726. for i = 1, 13, 1 do
  727. turtle.select(9)
  728. turtle.placeDown()
  729. if turtle.detect() then
  730. turtle.dig()
  731. end
  732. if turtle.detectUp() then
  733. turtle.digUp()
  734. end
  735. turtle.forward()
  736. end
  737. turtle.turnRight()
  738. drawHeader()
  739. Refuel()
  740. for i = 1, 13, 1 do
  741. turtle.select(9)
  742. turtle.placeDown()
  743. if turtle.detect() then
  744. turtle.dig()
  745. end
  746. if turtle.detectUp() then
  747. turtle.digUp()
  748. end
  749. turtle.forward()
  750. end
  751.  
  752. turtle.forward()
  753. turtle.turnRight()
  754. turtle.back()
  755. turtle.down()
  756.  
  757. end
  758.  
  759. if internalselection==3 then
  760. term.clear()
  761. term.setCursorPos(1,1)
  762. internalselection=0
  763. selection=0
  764. main()
  765. end
  766. end
  767.  
  768.  
  769. function Refuel()
  770. if fuel < 20 then
  771. turtle.select(16)
  772. turtle.refuel(1)
  773. turtle.select(1)
  774. end
  775. --Reload Dirt
  776. turtle.select(1)
  777. --if turtle.compareTo(13) then
  778. turtle.select(2)
  779. turtle.transferTo(1, 64)
  780. turtle.select(3)
  781. turtle.transferTo(2, 64)
  782. turtle.select(4)
  783. turtle.transferTo(3, 64)
  784. --end
  785. --Reload cobble
  786. turtle.select(5)
  787. --if turtle.compareTo(13) then
  788. turtle.select(6)
  789. turtle.transferTo(5, 64)
  790. turtle.select(7)
  791. turtle.transferTo(6, 64)
  792. turtle.select(8)
  793. turtle.transferTo(7, 64)
  794. --end
  795. --Reload track
  796. turtle.select(9)
  797. --if turtle.compareTo(13) then
  798. turtle.select(10)
  799. turtle.transferTo(9, 64)
  800. turtle.select(11)
  801. turtle.transferTo(10, 64)
  802. --end
  803. turtle.select(12)
  804. turtle.drop(64)
  805. turtle.select(13)
  806. turtle.drop(64)
  807. end
  808.  
  809.  
  810. function main()
  811. --PROGRAM START
  812. term.clear()
  813. term.setCursorPos(1,1)
  814.  
  815. while true do
  816. drawHeader()
  817. drawMainMenu()
  818. Refuel()
  819.  
  820. if selection==1 then
  821. forward()
  822. end
  823.  
  824. if selection==2 then
  825. backward()
  826. end
  827.  
  828. if selection==3 then
  829. turtle.turnLeft()
  830. term.clear()
  831. term.setCursorPos(1,1)
  832. end
  833.  
  834. if selection==4 then
  835. turtle.turnRight()
  836. term.clear()
  837. term.setCursorPos(1,1)
  838. end
  839.  
  840. if selection==5 then
  841. up()
  842. end
  843.  
  844. if selection==6 then
  845. down()
  846. end
  847.  
  848. if selection==7 then
  849. startfarm()
  850. end
  851.  
  852. if selection==8 then
  853. term.clear()
  854. term.setCursorPos(1,1)
  855. break
  856. end
  857.  
  858. end
  859. end
  860.  
  861. main()
Advertisement
Add Comment
Please, Sign In to add comment