Advertisement
visiongaming43

Untitled

Sep 19th, 2021
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. ---@diagnostic disable: lowercase-global
  2. -- Getting fuel level
  3. local fuelLevel = turtle.getFuelLevel()
  4.  
  5. -- Getting GPS coordinates
  6. local x1, y1, z1 = gps.locate()
  7.  
  8. -- Asking user for length and width
  9. print("How far do you want the turtle to go in front")
  10. local length = io.read()
  11.  
  12. print("How far do you want the turtle to go to the side")
  13. local width = io.read()
  14.  
  15. -- Asking for direction
  16. print("Would you like the turtle to go left (after it moves one forward) ONLY TYPE 'True' OR 'False'")
  17. local direction = io.read()
  18.  
  19. local directionNew = direction
  20.  
  21. -- Getting fuel needed
  22. local fuelNeeded = (length*width) + 1 + (1/2*length) + (1/2*width)
  23.  
  24. -- Making function to get the slot index of the seed
  25. local function getSeedIndex()
  26. for slot = 1, 16, 1 do
  27. local item = turtle.getItemDetail(slot)
  28. if (item ~= nil) then
  29. if (string.match(item.name, "seed")) then
  30. return slot
  31. end
  32. end
  33. end
  34. end
  35.  
  36. -- Making function to take crops
  37. local function getCrop()
  38. local isBlock, data = turtle.inspectDown()
  39. if(isBlock)then
  40. if (string.match(data.name, "croptopia:") and data['state']['age'] == 7) then
  41. turtle.digDown()
  42. for i = 6, 1, -1
  43. do
  44. turtle.suckDown()
  45. seedIndex = getSeedIndex()
  46. if(seedIndex ~= nil) then
  47. turtle.select(seedIndex)
  48. turtle.placeDown()
  49. end
  50. end
  51. end
  52. else
  53. seedIndex = getSeedIndex()
  54. if(seedIndex ~= nil) then
  55. turtle.select(seedIndex)
  56. turtle.placeDown()
  57. end
  58. end
  59. end
  60.  
  61. if(fuelLevel > fuelNeeded) then
  62. for a = length, 1, -1
  63. do
  64. direction = not(direction)
  65. turtle.forward()
  66. getCrop()
  67.  
  68. if(direction) then
  69. turtle.turnLeft()
  70. else
  71. turtle.turnRight()
  72. end
  73.  
  74. for b = width-1, 1, -1
  75. do
  76. turtle.forward()
  77. getCrop()
  78. end
  79.  
  80. if(direction) then
  81. turtle.turnRight()
  82. else
  83. turtle.turnLeft()
  84. end
  85. end
  86.  
  87. turtle.turnRight()
  88. turtle.turnRight()
  89.  
  90. for c = length, 1, -1
  91. do
  92. turtle.forward()
  93. end
  94.  
  95. if (directionNew == false) then
  96. turtle.turnLeft()
  97. for d = width-1, 1, -1
  98. do
  99. turtle.forward()
  100. end
  101. turtle.turnLeft()
  102. else
  103. turtle.turnRight()
  104. for d = width-1, 1, -1
  105. do
  106. turtle.forward()
  107. end
  108. turtle.turnRight()
  109. end
  110.  
  111. -- Drops ALL the items gained from farming ( seeds and crops ) into chest below starting point
  112. for a = 1, 16, 1
  113. do
  114. turtle.select(a)
  115. turtle.dropDown(64)
  116. end
  117.  
  118. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement