Advertisement
visiongaming43

Untitled

Sep 20th, 2021
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. ---@diagnostic disable: lowercase-global
  2. -- Getting fuel level
  3. local fuelLevel = turtle.getFuelLevel()
  4.  
  5. local direction = true
  6.  
  7. local directionNew = direction
  8.  
  9. -- Getting fuel needed
  10. local fuelNeeded = (13*13) + 1 + (1/2*13) + (1/2*13)
  11.  
  12. -- Making function to get the slot index of the seed
  13. local function getSeedIndex()
  14. for slot = 1, 16, 1 do
  15. local item = turtle.getItemDetail(slot)
  16. if (item ~= nil) then
  17. if ( (string.match(item.name, "seed") ) or (string.match(item.name, "potato") ) or (string.match(item.name, "carrot") ) ) then
  18. return slot
  19. end
  20. end
  21. end
  22. end
  23.  
  24. -- Making function to take crops
  25. local function getCrop()
  26. local isBlock, data = turtle.inspectDown()
  27. if(isBlock)then
  28. if ( ( string.match(data.name, "croptopia:") or string.match(data.name, "wheat") or string.match(data.name, "potato") or string.match(data.name, "carrot"))and data['state']['age'] == 7) then
  29. turtle.digDown()
  30. for i = 6, 1, -1
  31. do
  32. turtle.suckDown()
  33. seedIndex = getSeedIndex()
  34. if(seedIndex ~= nil) then
  35. turtle.select(seedIndex)
  36. turtle.placeDown()
  37. end
  38. end
  39. end
  40. else
  41. seedIndex = getSeedIndex()
  42. if(seedIndex ~= nil) then
  43. turtle.select(seedIndex)
  44. turtle.placeDown()
  45. end
  46. end
  47. end
  48.  
  49. -- If there is enough fuel, run the code
  50. if(fuelLevel > fuelNeeded) then
  51. for a = 13, 1, -1
  52. do
  53. direction = not(direction)
  54. turtle.forward()
  55. getCrop()
  56.  
  57. if(direction) then
  58. turtle.turnLeft()
  59. else
  60. turtle.turnRight()
  61. end
  62.  
  63. for b = 13-1, 1, -1
  64. do
  65. turtle.forward()
  66. getCrop()
  67. end
  68.  
  69. if(direction) then
  70. turtle.turnRight()
  71. else
  72. turtle.turnLeft()
  73. end
  74. end
  75.  
  76. turtle.turnRight()
  77. turtle.turnRight()
  78.  
  79. for c = 13, 1, -1
  80. do
  81. turtle.forward()
  82. end
  83.  
  84. if (directionNew == false) then
  85. turtle.turnLeft()
  86. for d = 13-1, 1, -1
  87. do
  88. turtle.forward()
  89. end
  90. turtle.turnLeft()
  91. else
  92. turtle.turnRight()
  93. for d = 13-1, 1, -1
  94. do
  95. turtle.forward()
  96. end
  97. turtle.turnRight()
  98. end
  99.  
  100. -- Drops ALL the items gained from farming ( seeds and crops ) into chest below starting point
  101. for slot = 1, 16, 1
  102. do
  103. turtle.select(slot)
  104. turtle.dropDown(64)
  105. end
  106.  
  107. turtle.suckUp(8)
  108. turtle.refuel(8)
  109.  
  110. local timerID = os.startTimer(500)
  111. local event, id
  112. repeat
  113. event, id = os.pullEvent("timer")
  114. until id == timerID
  115. os.reboot()
  116.  
  117. end
  118.  
  119. print("TURTLE DOES NOT HAVE ENOUGH FUEL")
  120. print("Please refuel the turtle, then re-run the file 'startup'!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement