Advertisement
Illogical_Sapz

test4

Jan 24th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. -- Author: Flyboxx --
  2. -- Date: Dec/5/2014 --
  3. -- Version: 1.1 --
  4. -- Updated Jan/30/2017 to 1.1 --
  5.  
  6. clearscr = function()
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. end
  10.  
  11. clearscr()
  12.  
  13. print("====== Farmer ======")
  14. print("Ver 1.1")
  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. data = {}
  52. for i = 1,16,1 do
  53. turtle.select(i)
  54. if turtle.getItemCount(i) ~= 0 then
  55. data = turtle.getItemDetail()
  56. if data.name == "minecraft:wheat_seeds" then
  57. turtle.dropDown()
  58. elseif data.name == "minecraft:wheat" then
  59. turtle.turnLeft()
  60. turtle.drop()
  61. turtle.turnRight()
  62. else
  63. turtle.dropUp()
  64. end
  65. end
  66. end
  67. end
  68.  
  69. getFuel = function(arg1)
  70. if arg1 == "first" then
  71. print("Refueling...")
  72. turtle.turnRight()
  73. turtle.select(1)
  74. turtle.suck()
  75. end
  76.  
  77. turtle.refuel(1)
  78.  
  79. if turtle.getFuelLevel() < 99 then
  80. getFuel("notfirst")
  81. else
  82. --if turtle.getItemDetail().name == "minecraft:bucket" then--
  83. --turtle.dropUp()--
  84. --else
  85. --turtle.drop()--
  86. --end--
  87. turtle.turnLeft()
  88. end
  89. end
  90.  
  91. initFarm = function()
  92. clearInv()
  93.  
  94. if turtle.getFuelLevel() < 99 then
  95. getFuel("first")
  96. end
  97.  
  98. turtle.forward()
  99. setPos(1,1)
  100. end
  101.  
  102. initPlant = function()
  103. clearInv()
  104.  
  105. if turtle.getFuelLevel() < 99 then
  106. getFuel("first")
  107. end
  108.  
  109. turtle.select(1)
  110. turtle.suckDown(64)
  111. turtle.select(2)
  112. turtle.suckDown(16)
  113. turtle.select(1)
  114.  
  115. turtle.forward()
  116. setPos(1,1)
  117. end
  118.  
  119. -- ==========*Till Program*========== --
  120. till = function()
  121. initFarm()
  122. clearscr()
  123. print("Tilling...")
  124.  
  125. while(farming) do
  126.  
  127. turtle.digDown()
  128. turtle.suckDown()
  129.  
  130.  
  131. if xpos == 9 and ypos == 9 then
  132. returnHome()
  133. clearInv()
  134. break
  135. end
  136.  
  137. if ypos == 9 then
  138. turtle.turnRight()
  139. turtle.forward()
  140. xpos = xpos + 1
  141. turtle.turnRight()
  142. turtle.digDown()
  143. turtle.suckDown()
  144. ystep = -1
  145. end
  146.  
  147. if ypos == 1 and xpos ~= 1 then
  148. turtle.turnLeft()
  149. turtle.forward()
  150. xpos = xpos + 1
  151. turtle.turnLeft()
  152. turtle.digDown()
  153. turtle.suckDown()
  154. ystep = 1
  155. end
  156.  
  157. turtle.forward()
  158. ypos = ypos + ystep
  159.  
  160. end
  161. end
  162.  
  163. -- ==========*Plant Program*========== --
  164. plant = function()
  165. initPlant()
  166. clearscr()
  167. print("Planting...")
  168.  
  169. while(farming) do
  170.  
  171. turtle.placeDown()
  172. if turtle.getItemCount() == 0 then
  173. turtle.select(turtle.getSelectedSlot() + 1)
  174. end
  175.  
  176. if xpos == 9 and ypos == 9 then
  177. returnHome()
  178. turtle.select(1)
  179. break
  180. end
  181.  
  182. if ypos == 9 then
  183. turtle.turnRight()
  184. turtle.forward()
  185. xpos = xpos + 1
  186. turtle.turnRight()
  187. turtle.placeDown()
  188. ystep = -1
  189. end
  190.  
  191. if ypos == 1 and xpos ~= 1 then
  192. turtle.turnLeft()
  193. turtle.forward()
  194. xpos = xpos + 1
  195. turtle.turnLeft()
  196. turtle.placeDown()
  197. ystep = 1
  198. end
  199.  
  200. turtle.forward()
  201. ypos = ypos + ystep
  202.  
  203. end
  204. end
  205.  
  206. -- ==========*Harvest Program*========== --
  207. harvest = function()
  208. initFarm()
  209. clearscr()
  210. print("Harvesting...")
  211.  
  212. while(farming) do
  213.  
  214. turtle.digDown()
  215. turtle.suckDown()
  216.  
  217. if xpos == 9 and ypos == 9 then
  218. returnHome()
  219. clearInv()
  220. turtle.select(1)
  221. break
  222. end
  223.  
  224. if ypos == 9 then
  225. turtle.turnRight()
  226. turtle.forward()
  227. xpos = xpos + 1
  228. turtle.turnRight()
  229. turtle.digDown()
  230. turtle.suckDown()
  231. ystep = -1
  232. end
  233.  
  234. if ypos == 1 and xpos ~= 1 then
  235. turtle.turnLeft()
  236. turtle.forward()
  237. xpos = xpos + 1
  238. turtle.turnLeft()
  239. turtle.digDown()
  240. turtle.suckDown()
  241. ystep = 1
  242. end
  243.  
  244. turtle.forward()
  245. turtle.suckDown()
  246. ypos = ypos + ystep
  247.  
  248. end
  249. end
  250.  
  251. -- ==========*Main Program*========== --
  252. till()
  253. while(farming) do
  254. plant()
  255. os.sleep( 4000 )
  256. harvest()
  257. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement