visiongaming43

Untitled

Sep 23rd, 2021
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. ---@diagnostic disable: lowercase-global
  2. -- Getting fuel level
  3. local fuelLevel = turtle.getFuelLevel()
  4.  
  5. -- Change it to false if you want turtle to go left instead of right
  6. local direction = true
  7.  
  8. local directionNew = direction
  9.  
  10. -- Calculating the amount of fuel needed and storing it in fuelNeeded
  11. local fuelNeeded = (13*13) + 27
  12.  
  13. -- Making function to get the slot index of the seed
  14. local function getSeedIndex()
  15. for slot = 1, 16, 1 do
  16. local item = turtle.getItemDetail(slot)
  17. if ( (item ~= nil) and ( (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.  
  23. -- Making function to take crops
  24. local function getCrop()
  25. local isBlock, data = turtle.inspectDown()
  26. if(isBlock)then
  27. 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
  28. turtle.digDown()
  29. for i = 6, 1, -1
  30. do
  31. turtle.suckDown()
  32. end
  33. seedIndex = getSeedIndex()
  34. if(seedIndex ~= nil) then
  35. turtle.select(seedIndex)
  36. turtle.placeDown()
  37. end
  38. end
  39. else
  40. seedIndex = getSeedIndex()
  41. if(seedIndex ~= nil) then
  42. turtle.digDown()
  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. -- Takes 8 items from the chest above it (MEANT TO TAKE COAL OR OTHER HIGH FUEL AMOUNT ITEM)
  108. turtle.suckUp(4)
  109. turtle.refuel(4)
  110.  
  111. -- Starts a timer that lasts 500 seconds. After the timer ends, the turtle reboots, and therefore repeats the program (Assuming the program is named 'startup' and has fuel)
  112. local timerID = os.startTimer(500)
  113. local event, id
  114. repeat
  115. event, id = os.pullEvent("timer")
  116. until id == timerID
  117. os.reboot()
  118.  
  119. end
  120.  
  121. -- If the turtle doesn't have fuel, it will display this message telling the user to feed it or fuck off
  122. term.blit("Error - Turtle does not have enough fuel!", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "fffffffffffffffffffffffffffffffffffffffff")
  123. term.blit("Please refuel the turtle using a fuel item and using the refuel() command!", "66666666666666666666666666666666666666666666666666666666666666666666666666", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
Add Comment
Please, Sign In to add comment