Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 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. -- ==========*Plant Program*========== --
  103. plant = function()
  104. initPlant()
  105. clearscr()
  106. print("Planting...")
  107.  
  108. while(farming) do
  109.  
  110. turtle.placeDown()
  111. if turtle.getItemCount() == 0 then
  112. turtle.select(turtle.getSelectedSlot() + 1)
  113. end
  114.  
  115. if xpos == 9 and ypos == 9 then
  116. returnHome()
  117. turtle.select(1)
  118. break
  119. end
  120.  
  121. if ypos == 9 then
  122. turtle.turnRight()
  123. turtle.forward()
  124. xpos = xpos + 1
  125. turtle.turnRight()
  126. turtle.placeDown()
  127. ystep = -1
  128. end
  129.  
  130. if ypos == 1 and xpos ~= 1 then
  131. turtle.turnLeft()
  132. turtle.forward()
  133. xpos = xpos + 1
  134. turtle.turnLeft()
  135. turtle.placeDown()
  136. ystep = 1
  137. end
  138.  
  139. turtle.forward()
  140. ypos = ypos + ystep
  141.  
  142. end
  143. end
  144.  
  145. -- ==========*Harvest Program*========== --
  146. harvest = function()
  147. initFarm()
  148. clearscr()
  149. print("Harvesting...")
  150.  
  151. while(farming) do
  152.  
  153. turtle.digDown()
  154.  
  155. if xpos == 9 and ypos == 9 then
  156. returnHome()
  157. clearInv()
  158. turtle.select(1)
  159. break
  160. end
  161.  
  162. if ypos == 9 then
  163. turtle.turnRight()
  164. turtle.forward()
  165. xpos = xpos + 1
  166. turtle.turnRight()
  167. turtle.digDown()
  168. ystep = -1
  169. end
  170.  
  171. if ypos == 1 and xpos ~= 1 then
  172. turtle.turnLeft()
  173. turtle.forward()
  174. xpos = xpos + 1
  175. turtle.turnLeft()
  176. turtle.digDown()
  177. ystep = 1
  178. end
  179.  
  180. turtle.forward()
  181. ypos = ypos + ystep
  182.  
  183. end
  184. end
  185.  
  186. -- ==========*Main Program*========== --
  187. while(farming) do
  188. harvest()
  189. plant()
  190. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement