visiongaming43

Untitled

Sep 23rd, 2021
36
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. break
  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. end
  34. seedIndex = getSeedIndex()
  35. if(seedIndex ~= nil) then
  36. turtle.select(seedIndex)
  37. turtle.placeDown()
  38. end
  39. end
  40. else
  41. seedIndex = getSeedIndex()
  42. if(seedIndex ~= nil) then
  43. turtle.digDown()
  44. turtle.select(seedIndex)
  45. turtle.placeDown()
  46. end
  47. end
  48. end
  49.  
  50. -- If there is enough fuel, run the code
  51. if(fuelLevel > fuelNeeded) then
  52. for a = 13, 1, -1
  53. do
  54. direction = not(direction)
  55. turtle.forward()
  56. getCrop()
  57.  
  58. if(direction) then
  59. turtle.turnLeft()
  60. else
  61. turtle.turnRight()
  62. end
  63.  
  64. for b = 13-1, 1, -1
  65. do
  66. turtle.forward()
  67. getCrop()
  68. end
  69.  
  70. if(direction) then
  71. turtle.turnRight()
  72. else
  73. turtle.turnLeft()
  74. end
  75. end
  76.  
  77. turtle.turnRight()
  78. turtle.turnRight()
  79.  
  80. for c = 13, 1, -1
  81. do
  82. turtle.forward()
  83. end
  84.  
  85. if (directionNew == false) then
  86. turtle.turnLeft()
  87. for d = 13-1, 1, -1
  88. do
  89. turtle.forward()
  90. end
  91. turtle.turnLeft()
  92. else
  93. turtle.turnRight()
  94. for d = 13-1, 1, -1
  95. do
  96. turtle.forward()
  97. end
  98. turtle.turnRight()
  99. end
  100.  
  101. -- Drops ALL the items gained from farming ( seeds and crops ) into chest below starting point
  102. for slot = 1, 16, 1
  103. do
  104. turtle.select(slot)
  105. turtle.dropDown(64)
  106. end
  107.  
  108. -- Takes 8 items from the chest above it (MEANT TO TAKE COAL OR OTHER HIGH FUEL AMOUNT ITEM)
  109. turtle.suckUp(8)
  110. turtle.refuel(8)
  111.  
  112. -- 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)
  113. local timerID = os.startTimer(500)
  114. local event, id
  115. repeat
  116. event, id = os.pullEvent("timer")
  117. until id == timerID
  118. os.reboot()
  119.  
  120. end
  121.  
  122. -- If the turtle doesn't have fuel, it will display this message telling the user to feed it or fuck off
  123. term.blit("Error - Turtle does not have enough fuel!", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "fffffffffffffffffffffffffffffffff")
  124. 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