SHARE
TWEET

Untitled

a guest Jul 21st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[ SETTINGS ]]--
  2. X=9
  3. Y=9
  4. sendID=-1
  5. plant = "true"
  6. fuelID="minecraft:coal"
  7. sleepOnLoad=20
  8. --[[    END   ]]--
  9.  
  10.  
  11.  
  12. Status="on the Wrong Block :/"
  13. xb=1
  14. shell.run("clear")
  15. right="false"
  16. pause="false"
  17. stop="false"
  18. local fin="false"
  19. local f = Y*X+Y+X+10
  20. sId = tonumber(sendID)
  21.  
  22.  
  23. local function unload()
  24. if pause == "true" then
  25. fin ="true"
  26. shell.run(shell.getRunningProgram())
  27. else
  28. end
  29. Status="Loading/Unloading"
  30. for a=1,14 do
  31. turtle.select(a)
  32. turtle.dropDown()
  33. end
  34. for item=1, 16 do
  35. Isuc, Iname = turtle.getItemDetail()
  36. turtle.select(14)
  37. turtle.suckDown()
  38. if Iname == "minecraft:wheat_seeds" or "minecraft:carrot" or "minecraft:potato" or "Natura:barley.seeds" then
  39. turtle.transferTo(15)
  40. elseif Iname == FuelID then
  41. turtle.transferTo(16)
  42. end
  43. turtle.select(14)
  44. turtle.dropDown()
  45. end
  46. Status="sleeping"
  47. sleep(sleepOnLoad)
  48. turtle.select(16)
  49. turtle.refuel()
  50. turtle.select(14)
  51. turtle.dropDown()
  52. turtle.select(1)
  53. turtle.forward()
  54.  
  55. xb=1
  56. right="false"
  57. end
  58.  
  59.  
  60. local function Fplant()
  61. Status = "planting"
  62. sucess, data = turtle.inspectDown()
  63. if plant == "true" then
  64. turtle.select(15)
  65. turtle.placeDown()
  66. turtle.select(1)
  67. else
  68. end
  69.  
  70. end
  71.  
  72.  
  73. local function detect()
  74. if pause == "true" then
  75. else
  76. Status = "moving forward"
  77. sucess, data = turtle.inspectDown()
  78. if sucess == true then
  79.  if data.metadata == 7 then
  80.  Status = "farming"
  81.  turtle.digDown()
  82.  turtle.suckDown(2)
  83.  turtle.select(2)
  84.  turtle.transferTo(15)
  85.   turtle.select(1)
  86.  sleep(0.2)
  87.  Fplant()
  88.  end
  89. else
  90. turtle.digDown()
  91. Fplant()
  92. end
  93. end
  94. end
  95.  
  96. local function curve()
  97. sucess, data = turtle.inspectDown()
  98. if right == "false" then
  99. xb = xb+1
  100. if xb <= X then
  101. detect()
  102. Status = "turning to the right"
  103. turtle.turnRight()
  104. turtle.forward()
  105. turtle.turnRight()
  106. right = "true"
  107. end
  108.  
  109. elseif right == "true" then
  110. xb = xb+1
  111. if xb <= X then
  112. detect()
  113. Status = "turning to the left"
  114. turtle.turnLeft()
  115. turtle.forward()
  116. turtle.turnLeft()
  117. right = "false"
  118. end
  119. end
  120. end
  121.  
  122. local function back()
  123. detect()
  124. Status = "going back"
  125.  if right == "true" then
  126.  turtle.turnRight()
  127. detect()
  128. for i1=3,xb do
  129. turtle.forward()
  130.  
  131. end
  132. turtle.turnLeft()
  133. turtle.forward()
  134. turtle.turnLeft()
  135. turtle.turnLeft()
  136. unload()
  137. end
  138.  
  139.  
  140. if right == "false" then
  141. turtle.turnLeft()
  142. turtle.turnLeft()
  143. detect()
  144. for i2=2,Y do
  145. turtle.forward()
  146. end
  147. turtle.turnRight()
  148.  
  149. for i1=3,xb do
  150. turtle.forward()
  151.  
  152. end
  153. turtle.turnLeft()
  154. turtle.forward()
  155. turtle.turnLeft()
  156. turtle.turnLeft()
  157. unload()
  158. end
  159. end
  160.  
  161. local function send()
  162.  
  163. local function opnmdm()
  164. for i,v in pairs(rs.getSides()) do
  165.   if peripheral.getType(v) == "modem" then
  166.    if not rednet.isOpen(v) then rednet.open(v) end
  167.   return true end
  168. end
  169. return false end
  170.  
  171. opnmdm()
  172.  
  173. while fin == "false" do
  174. Id, message, protocol = rednet.receive()
  175. if Id == sendID then
  176.  
  177. if not os.getComputerLabel() then
  178. os.setComputerLabel("FeelingTurtle")
  179. end
  180.  
  181. if message == "stop" then
  182. Status = "Stopped"
  183. stop = "true"
  184. sleep(1)
  185. rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] Stopped!")
  186. end
  187.  
  188.  
  189. if message == "resume" then
  190. Status = "on the wrong block :/"
  191. stop = "false"
  192. sleep(1)
  193. rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] Resumed")
  194. end
  195.  
  196.  
  197. if message == "status" then
  198. sleep(1)
  199. rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] is "..Status)
  200. end
  201.  
  202. if message == "fuel" then
  203. sleep(1)
  204. rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] has "..turtle.getFuelLevel().." Fuel!")
  205. end
  206.  
  207. if message == "type" then
  208. sleep(1)
  209. rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] Is a Farming Turtle!")
  210. end
  211.  
  212. if message == "help" then
  213. sleep(1)
  214. rednet.send(sId, os.getComputerLabel() .."[".. os.getComputerID() .."] Commands: stop, resume, status, fuel, type")
  215. end
  216.  
  217. if message and message ~= "" then
  218. rednet.send(sId, "Invalid command!")
  219. message=""
  220. else
  221.  
  222. end
  223. end
  224. end
  225. end
  226.  
  227. local function ui()
  228. while fin == "false" do
  229. x1, y1 = term.getSize()
  230. x2, y2 = term.getCursorPos()
  231. text = os.getComputerLabel().."[".. os.getComputerID().."]"
  232. term.setCursorPos(x1/2/string.len(text)+1,1)
  233. print(text)
  234. text = " Status: Is ".. Status.."              "
  235. term.setCursorPos(x1/2/string.len(text),3)
  236. print(text)
  237. term.setCursorPos(1,4)
  238. print("---------------------------------------")
  239. sleep(0.01)
  240. term.setCursorPos(1,y2)
  241. end
  242. end
  243.  
  244. local function shellP()
  245.  
  246. while fin == "false" do
  247. x2, y2 = term.getCursorPos()
  248.  
  249. if y2 > 13 then
  250. term.clear()
  251.  term.setCursorPos(1,5)
  252.  elseif y2 < 5 then
  253.  term.setCursorPos(1,5)
  254.  else
  255.  end
  256.  
  257. write("> ")
  258. c = read()
  259.  
  260. if c == "stop" then
  261. Status = "Stopped"
  262. stop = "true"
  263. print(os.getComputerLabel() .."[".. os.getComputerID() .."] Stopped!")
  264.  
  265. elseif c == "resume" then
  266. Status = "sleeping"
  267. stop = "false"
  268. print(os.getComputerLabel() .."[".. os.getComputerID() .."] Resumed")
  269.  
  270. elseif c == "status" then
  271. print(os.getComputerLabel() .."[".. os.getComputerID() .."] is "..Status)
  272.  
  273. elseif c == "fuel" then
  274. print(os.getComputerLabel() .."[".. os.getComputerID() .."] has "..turtle.getFuelLevel().." Fuel!")
  275.  
  276.  
  277.  
  278. elseif c == "type" then
  279. print(os.getComputerLabel() .."[".. os.getComputerID() .."] Is a Felling Turtle!")
  280.  
  281.  
  282. elseif c == "exit" then
  283. print("Terminated!")
  284. pause = "true"
  285. turtle.select(1)
  286. sleep(0.5)
  287. os.reboot()
  288. elseif c == "help" then
  289. print("Commands: ")
  290. print("stop, resume, status, fuel, type, exit")
  291. else
  292. print("Invalid Command!")
  293.  
  294.  
  295. end
  296. sleep(2)
  297. term.clear()
  298. end
  299. end
  300.  
  301. local function main()
  302. os.pullEvent =os.pullEventRaw
  303. unload()
  304. while turtle.getFuelLevel() < f do
  305. sleep(1)
  306. Status="out of Fuel!"
  307. turtle.select(16)
  308. turtle.refuel(64)
  309. end
  310. while true do
  311. if pause == "false" and stop == "false" then
  312. for i3=2,Y do
  313. detect()
  314. turtle.forward()
  315. end
  316. curve()
  317.  
  318. if X < xb then
  319. pause="true"
  320.  
  321. back()
  322. end
  323.  
  324. end
  325. end
  326. sleep(0.01)
  327. end
  328.  
  329.  
  330. parallel.waitForAny(ui, send, shellP, main)
  331. shell.run(shell.getRunningProgram())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top