Advertisement
zeshan

Untitled

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