bldng1

Farmer

Jul 28th, 2021 (edited)
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. --Farmer
  2. os.loadAPI("bldng/lib")
  3. status="start"
  4. lap=false
  5. xd=1
  6. yd=1
  7. lib.fstd({xd=xd,yd=yd,lap=lap,status=status})
  8. function setStatus(str)
  9. status=str
  10. fsave({status=status,xd=xd,yd=yd,lap=lap})
  11. end
  12. function plant()
  13. if turtle.detectDown() and lib.getFBlockdatad().state.age==7 then
  14. turtle.digDown()
  15. lib.setItem("seed",1)
  16. turtle.select(1)
  17. turtle.placeDown()
  18. end
  19. end
  20. if(lib.isResumed()) then
  21. xd=tonumber(lib.fload("xd"))
  22. yd=tonumber(lib.fload("yd"))
  23. lap=lib.tobool(lib.fload("lap"))
  24. status=lib.fload("status")
  25. plant()
  26. end
  27. lib.registerRunning(shell.getRunningProgram())
  28. while not lib.shouldret() do
  29. if lib.atSpawn() and status~="start" then
  30. setStatus("start")
  31. lib.clearInv()
  32. sleep(3600)
  33. end
  34. if status=="start" or status=="start2" then
  35. while not turtle.inspect() do
  36. lib.move(xd,0,0)
  37. plant()
  38. end
  39. setStatus("wall")
  40. end
  41. if status=="wall" then
  42. lib.rotate(lib.getMoveDir(0,yd))
  43. if turtle.inspect() then
  44. if yd<0 then
  45. yd=1
  46. else
  47. yd=-1
  48. end
  49. end
  50. lib.move(0,yd,0)
  51. setStatus("turn")
  52. end
  53. if status=="turn" then
  54. plant()
  55. if xd<0 then
  56. xd=1
  57. else
  58. xd=-1
  59. end
  60. lib.rotate(lib.getMoveDir(xd,0))
  61. setStatus("start2")
  62. end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment