Advertisement
ZeldaCorporation

COMPUTERCRAFT TURTLE CODE aWheatFarm

Jan 28th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. --[[aWheatFarm]]--
  2. --[[By: ThePhoenixSol]]--
  3. --[[Version 2.0]]--
  4.  
  5. --[[Slot Designation]]--
  6. --# Slot 1 is seeds
  7. --# Slot 5-7 is wheat
  8. --# Slot 2 is fuel
  9.  
  10. --[[VARIABLES]]--
  11. local cycle = true
  12. local cyc = 6
  13. local cycTwo = 4
  14. local cycThree = 2
  15. local incNum = 0
  16.  
  17. --[[FUNCTIONS]]--
  18. function refueling()
  19. term.clear()
  20. term.setCursorPos(1, 1)
  21. print("=======================================")
  22. print("Warning: Out of Fuel... Refueling")
  23. print("=======================================")
  24. end
  25.  
  26. function crafting()
  27. term.clear()
  28. term.setCursorPos(1, 1)
  29. print("=======================================")
  30. print("Crafting...")
  31. print("=======================================")
  32. end
  33.  
  34. function running()
  35. term.clear()
  36. term.setCursorPos(1, 1)
  37. print("=======================================")
  38. print("Running...")
  39. print("=======================================")
  40. end
  41.  
  42. function wait()
  43. term.clear()
  44. term.setCursorPos(1, 1)
  45. print("=======================================")
  46. print("Waiting...")
  47. print("=======================================")
  48. os.sleep(120)
  49. end
  50.  
  51. function refuel()
  52. local fuelLevel = turtle.getFuelLevel()
  53. if fuelLevel < 300 then
  54. refueling()
  55. turtle.turnRight()
  56. turtle.select(2)
  57. turtle.suck()
  58. turtle.refuel()
  59. turtle.turnLeft()
  60. end
  61. end
  62.  
  63. function InvEmp()
  64. for i = 1, 4 do
  65. turtle.select(i)
  66. turtle.dropDown()
  67. end
  68. for i = 8, 16 do
  69. turtle.select(i)
  70. turtle.dropDown()
  71. end
  72. turtle.select(8)
  73. turtle.dropDown()
  74. end
  75.  
  76. function craft()
  77. crafting()
  78. turtle.turnLeft()
  79. turtle.select(1)
  80. turtle.drop()
  81. turtle.select(2)
  82. turtle.drop()
  83. InvEmp()
  84. turtle.select(16)
  85. turtle.craft()
  86. turtle.dropDown()
  87. turtle.select(1)
  88. turtle.suck()
  89. turtle.select(2)
  90. turtle.suck()
  91. turtle.turnRight()
  92. end
  93.  
  94. function fetchSeed()
  95. for i = 1, 16 do
  96. local data = turtle.getItemDetail(i)
  97. local seedAmt = turtle.getItemCount(1)
  98. if data and data.name == "minecraft:wheat_seeds" then
  99. turtle.select(i)
  100. if seedAmt < 60 then
  101. turtle.transferTo(1)
  102. else
  103. turtle.dropDown(30)
  104. end
  105. end
  106. end
  107. end
  108.  
  109. function replant()
  110. fetchSeed()
  111. turtle.select(1)
  112. turtle.placeDown()
  113. end
  114.  
  115. function harvest()
  116. local success, data = turtle.inspectDown()
  117. if success and data.name == "minecraft:wheat" and data.metadata == 7 then
  118. for i = 5, 7 do
  119. if turtle.getItemCount(i) < 64 then
  120. turtle.select(i)
  121. turtle.digDown()
  122. replant()
  123. return
  124. end
  125. end
  126. end
  127. end
  128.  
  129. function forwFarm()
  130. turtle.forward()
  131. harvest()
  132. end
  133.  
  134. function rightForwLayOne()
  135. turtle.turnRight()
  136. while cyc > incNum do
  137. forwFarm()
  138. incNum = incNum + 1
  139. end
  140. incNum = 0
  141. end
  142.  
  143. function rightForwLayTwo()
  144. turtle.turnRight()
  145. while cycTwo > incNum do
  146. forwFarm()
  147. incNum = incNum + 1
  148. end
  149. incNum = 0
  150. end
  151.  
  152. function rightForwLayThree()
  153. turtle.turnRight()
  154. while cycThree > incNum do
  155. forwFarm()
  156. incNum = incNum + 1
  157. end
  158. incNum = 0
  159. end
  160.  
  161. function returnHome()
  162. turtle.turnRight()
  163. turtle.forward()
  164. turtle.turnLeft()
  165. turtle.forward()
  166. turtle.forward()
  167. turtle.forward()
  168. turtle.down()
  169. turtle.turnLeft()
  170. turtle.turnLeft()
  171. end
  172.  
  173. function status()
  174. running()
  175. turtle.up()
  176. forwFarm()
  177. turtle.turnLeft()
  178. forwFarm()
  179. forwFarm()
  180. forwFarm()
  181. rightForwLayOne()
  182. rightForwLayOne()
  183. rightForwLayOne()
  184. turtle.turnRight()
  185. forwFarm()
  186. forwFarm()
  187. forwFarm()
  188. turtle.turnRight()
  189. forwFarm()
  190. turtle.turnLeft()
  191. forwFarm()
  192. forwFarm()
  193. rightForwLayTwo()
  194. rightForwLayTwo()
  195. rightForwLayTwo()
  196. turtle.turnRight()
  197. forwFarm()
  198. forwFarm()
  199. turtle.turnRight()
  200. forwFarm()
  201. turtle.turnLeft()
  202. forwFarm()
  203. rightForwLayThree()
  204. rightForwLayThree()
  205. rightForwLayThree()
  206. returnHome()
  207. end
  208.  
  209. --[[MAIN]]--
  210.  
  211. while cycle do
  212. refuel()
  213. status()
  214. craft()
  215. wait()
  216. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement