Advertisement
xbsktball10x

Till 2.0

May 20th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. shell.run("getTill")
  2. print("1.3")
  3.  
  4. local i = 1
  5. local x = 1
  6. local y = 1
  7. local z = 0
  8.  
  9. local function plant(i)
  10. local c = 0
  11. turtle.select(x)
  12. if turtle.getItemCount(x) == 0 then
  13. repeat turtle.select(i+1)
  14. i = i + 1
  15. if i == 15 then
  16. i = 1
  17. c = c+1
  18. end
  19. if c == 2 then
  20. goHome(y)
  21. end
  22. until turtle.getItemCount(i) > 0
  23. end
  24. turtle.dig()
  25. turtle.place()
  26. if turtle.back() == false then
  27. repeat turtle.back()
  28. until turtle.back()
  29. end
  30.  
  31. end
  32.  
  33. local function refill()
  34. for z = 1,15 do
  35. turtle.select(z)
  36. turtle.suckDown()
  37. end
  38. end
  39. local function empty()
  40. for x=1,15 do
  41. turtle.select(x)
  42. turtle.dropDown()
  43. end
  44. end
  45. local function turnAround(y)
  46. if y%2 == 1 then
  47. turtle.turnRight()
  48. if turtle.back() == false then
  49. repeat turtle.back()
  50. until turtle.back()
  51. end
  52. turtle.turnRight()
  53. end
  54. if y%2 == 0 then
  55. turtle.turnLeft()
  56. if turtle.back() == false then
  57. repeat turtle.back()
  58. until turtle.back()
  59. end
  60. turtle.turnLeft()
  61. end
  62. end
  63. local function goHome(y)
  64. if y%2 == 1 then
  65. turtle.turnLeft()
  66. turtle.turnLeft()
  67. end
  68. repeat turtle.back()
  69. until turtle.back() == false
  70. turtle.turnRight()
  71. repeat turtle.back()
  72. y = y - 1
  73. until y == 1
  74. turtle.down()
  75. turtle.turnRight()
  76. end
  77. local function till()
  78. repeat
  79. plant(i)
  80. turtle.select(16)
  81. until turtle.compareDown()
  82. turtle.select(x)
  83. if turtle.getItemCount(x) == 0 then
  84. repeat turtle.select(i+1)
  85. i = i + 1
  86. if i == 15 then
  87. goHome(y)
  88. i = 1
  89. end
  90. until turtle.getItemCount(i) > 0
  91. end
  92. turtle.dig()
  93. turtle.place()
  94. turnAround(y)
  95. end
  96. local function endOfPlotCheck()
  97. turtle.select(16)
  98. if turtle.compareDown() == true then
  99. turtle.back()
  100. if turtle.compareDown() == true then
  101. return true
  102. end
  103. end
  104. end
  105. while true do
  106.  
  107. turtle.select(1)
  108. rednet.open("right")
  109. local senderId, msg = rednet.receive()
  110.  
  111. if msg == "farm" then
  112. refill()
  113. repeat
  114. till()
  115. y = y + 1
  116. until endOfPlotCheck()
  117. goHome(y)
  118. empty()
  119. os.reboot()
  120. end
  121. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement