Advertisement
visiongaming43

Untitled

Sep 21st, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 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.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. turtle.suckUp(8)
  109. turtle.refuel(8)
  110.  
  111. local timerID = os.startTimer(500)
  112. local event, id
  113. repeat
  114. event, id = os.pullEvent("timer")
  115. until id == timerID
  116. os.reboot()
  117.  
  118. end
  119.  
  120. term.blit("Error - Turtle does not have enough fuel!", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "fffffffffffffffffffffffffffffffff")
  121. term.blit("Please refuel the turtle using a fuel item and using the refuel() command!", "66666666666666666666666666666666666666666666666666666666666666666666666666", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement