zeshan

Untitled

Dec 15th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.44 KB | None | 0 0
  1. -- Author: Flyboxx --
  2. -- Modifed: ZeeZee --
  3. -- Date: Dec/5/2014 --
  4. -- Version: TEKKIT --
  5. -- Updated Dec/15/2019 to TEKKIT --
  6.  
  7. clearscr = function()
  8. term.clear()
  9. term.setCursorPos(1,1)
  10. end
  11.  
  12. clearscr()
  13.  
  14. print("====== Farmer ======")
  15. print("Ver TEKKIT")
  16. print("By Flyboxx")
  17.  
  18. sleep(1)
  19. clearscr()
  20.  
  21. -- Variables --
  22.  
  23. local args = {...}
  24. farming = true
  25. ystep = 1
  26. xpos = 1
  27. ypos = 0
  28.  
  29. -- Init --
  30.  
  31. -- Functions --
  32.  
  33. setPos = function(x, y)
  34. xpos = x
  35. ypos = y
  36. end
  37.  
  38. returnHome = function()
  39. turtle.turnLeft()
  40. for i = 1, 8, 1 do
  41. turtle.forward()
  42. end
  43. turtle.turnLeft()
  44. for i = 1, 9, 1 do
  45. turtle.forward()
  46. end
  47. turtle.turnLeft()
  48. turtle.turnLeft()
  49. end
  50.  
  51. clearInv = function()
  52. for i = 1,14,1 do
  53. turtle.select(i)
  54. if turtle.getItemCount(i) ~= 0 then
  55. if turtle.compareTo(15) then
  56. turtle.dropDown()
  57. elseif turtle.compareTo(16) then
  58. turtle.turnLeft()
  59. turtle.drop()
  60. turtle.turnRight()
  61. else
  62. turtle.dropUp()
  63. end
  64. end
  65. end
  66. end
  67.  
  68. getFuel = function(arg1)
  69. if arg1 == "first" then
  70. print("Refueling...")
  71. turtle.turnRight()
  72. turtle.select(1)
  73. turtle.suck()
  74. end
  75.  
  76. turtle.refuel(1)
  77.  
  78. if turtle.getFuelLevel() < 99 then
  79. getFuel("notfirst")
  80. else
  81. turtle.drop()
  82. turtle.turnLeft()
  83. end
  84. end
  85.  
  86. initFarm = function()
  87. clearInv()
  88.  
  89. if turtle.getFuelLevel() < 99 then
  90. getFuel("first")
  91. end
  92.  
  93. turtle.forward()
  94. setPos(1,1)
  95. end
  96.  
  97. initPlant = function()
  98. clearInv()
  99.  
  100. if turtle.getFuelLevel() < 99 then
  101. getFuel("first")
  102. end
  103.  
  104. turtle.select(1)
  105. turtle.suckDown(64)
  106. turtle.select(2)
  107. turtle.suckDown(16)
  108. turtle.select(1)
  109.  
  110. turtle.forward()
  111. setPos(1,1)
  112. end
  113.  
  114. initFert = function()
  115. clearInv()
  116.  
  117. if turtle.getFuelLevel() < 99 then
  118. getFuel("first")
  119. end
  120.  
  121. turtle.select(1)
  122. turtle.suckUp(64)
  123. turtle.select(2)
  124. turtle.suckUp(64)
  125. turtle.select(3)
  126. turtle.suckUp(64)
  127. turtle.select(4)
  128. turtle.suckUp(64)
  129.  
  130. checkFertInv(1)
  131.  
  132. turtle.forward()
  133. setPos(1,1)
  134. turtle.select(1)
  135. end
  136.  
  137. checkFertInv = function(slot)
  138. for i = 1, 4 , 1 do
  139. if turtle.getItemCount(i) ~= 64 then
  140. print("Slot " .. i .. " needs to have 64 items!");
  141. while(turtle.getItemCount(i) ~= 64) do
  142. sleep(2)
  143. turtle.select(i)
  144. turtle.suckUp()
  145. end
  146. end
  147. end
  148. turtle.select(1)
  149. end
  150.  
  151. fert = function()
  152. for i = 1, 5, 1 do
  153. turtle.placeDown()
  154. slot = 1
  155. while(turtle.getItemCount(slot) == 0)
  156. do
  157. slot = slot+1
  158. end
  159. turtle.select(slot)
  160. end
  161. end
  162.  
  163. -- ==========*Till Program*========== --
  164. till = function()
  165. initFarm()
  166. clearscr()
  167. print("Tilling...")
  168.  
  169. while(farming) do
  170.  
  171. turtle.digDown()
  172.  
  173. if xpos == 9 and ypos == 9 then
  174. returnHome()
  175. clearInv()
  176. break
  177. end
  178.  
  179. if ypos == 9 then
  180. turtle.turnRight()
  181. turtle.forward()
  182. xpos = xpos + 1
  183. turtle.turnRight()
  184. turtle.digDown()
  185. ystep = -1
  186. end
  187.  
  188. if ypos == 1 and xpos ~= 1 then
  189. turtle.turnLeft()
  190. turtle.forward()
  191. xpos = xpos + 1
  192. turtle.turnLeft()
  193. turtle.digDown()
  194. ystep = 1
  195. end
  196.  
  197. turtle.forward()
  198. ypos = ypos + ystep
  199.  
  200. end
  201. end
  202.  
  203. -- ==========*Plant Program*========== --
  204. plant = function()
  205. initPlant()
  206. clearscr()
  207. print("Planting...")
  208.  
  209. while(farming) do
  210.  
  211. turtle.placeDown()
  212.  
  213. slot = 1
  214. while(turtle.getItemCount(slot) == 0)
  215. do
  216. slot = slot+1
  217. end
  218. turtle.select(slot)
  219.  
  220. if xpos == 9 and ypos == 9 then
  221. returnHome()
  222. turtle.select(1)
  223. break
  224. end
  225.  
  226. if ypos == 9 then
  227. turtle.turnRight()
  228. turtle.forward()
  229. xpos = xpos + 1
  230. turtle.turnRight()
  231. turtle.placeDown()
  232. ystep = -1
  233. end
  234.  
  235. if ypos == 1 and xpos ~= 1 then
  236. turtle.turnLeft()
  237. turtle.forward()
  238. xpos = xpos + 1
  239. turtle.turnLeft()
  240. turtle.placeDown()
  241. ystep = 1
  242. end
  243.  
  244. turtle.forward()
  245. ypos = ypos + ystep
  246.  
  247. end
  248. end
  249.  
  250. -- ==========*Harvest Program*========== --
  251. harvest = function()
  252. initFarm()
  253. clearscr()
  254. print("Harvesting...")
  255.  
  256. while(farming) do
  257.  
  258. turtle.digDown()
  259.  
  260. if xpos == 9 and ypos == 9 then
  261. returnHome()
  262. clearInv()
  263. turtle.select(1)
  264. break
  265. end
  266.  
  267. if ypos == 9 then
  268. turtle.turnRight()
  269. turtle.forward()
  270. xpos = xpos + 1
  271. turtle.turnRight()
  272. turtle.digDown()
  273. ystep = -1
  274. end
  275.  
  276. if ypos == 1 and xpos ~= 1 then
  277. turtle.turnLeft()
  278. turtle.forward()
  279. xpos = xpos + 1
  280. turtle.turnLeft()
  281. turtle.digDown()
  282. ystep = 1
  283. end
  284.  
  285. turtle.forward()
  286. ypos = ypos + ystep
  287.  
  288. end
  289. end
  290.  
  291. -- ==========*Fertilize Program*========== --
  292. fertilize = function()
  293. initFert()
  294. clearscr()
  295. print("Fertilizing...")
  296.  
  297. while(farming) do
  298.  
  299. pos = {xpos, ypos}
  300.  
  301. fert()
  302.  
  303. if xpos == 9 and ypos == 9 then
  304. returnHome()
  305. clearInv()
  306. turtle.select(1)
  307. break
  308. end
  309.  
  310. if ypos == 9 then
  311. turtle.turnRight()
  312. turtle.forward()
  313. xpos = xpos + 1
  314. turtle.turnRight()
  315. fert()
  316. ystep = -1
  317. end
  318.  
  319. if ypos == 1 and xpos ~= 1 then
  320. turtle.turnLeft()
  321. turtle.forward()
  322. xpos = xpos + 1
  323. turtle.turnLeft()
  324. fert()
  325. ystep = 1
  326. end
  327.  
  328. turtle.forward()
  329. ypos = ypos + ystep
  330.  
  331. end
  332. end
  333.  
  334. -- ==========*Main Program*========== --
  335. till()
  336. while(farming) do
  337. plant()
  338. fertilize()
  339. harvest()
  340. end
Advertisement
Add Comment
Please, Sign In to add comment