Advertisement
Aetous

MC turtle harvest script

Feb 18th, 2020
700
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. print "[!]Harvester ready for action!"
  2.  
  3. --customization
  4. fieldsizex=9
  5. fieldsizey=9
  6.  
  7. minfuel=1500 --the minimum amount of fuel we should stock up on when done
  8.  
  9. --system variables, do not edit
  10. od = true --am I going in the Outward Direction
  11. df = false --done farming
  12.  
  13.  
  14. --function declarations
  15. function movePlace() --harvests, collects, replants, and moves
  16.     turtle.digDown()
  17.     turtle.suckDown(5)
  18.     turtle.placeDown()
  19.     turtle.forward()
  20. end
  21. function moveCollect() --collects the crops as it comes back
  22.     turtle.suckDown(5)
  23.     turtle.forward()
  24. end
  25. function waitFourMinutes()
  26.     print "[!]Sleeping for 4 minutes"
  27.     os.sleep(240)
  28. end
  29.  
  30.  
  31.  
  32. --main proccesses
  33. while true do
  34.  
  35. --prepare
  36. turtle.forward()
  37. turtle.turnLeft()
  38.  
  39. --farm
  40. for y=1,fieldsizey do
  41.     for x=1,fieldsizex-1 do --harvest across the field
  42.         movePlace()
  43.     end
  44.     turtle.turnRight() --spin around
  45.     turtle.digDown()
  46.     turtle.suckDown(5)
  47.     turtle.placeDown()
  48.     turtle.turnRight()
  49.     od = false
  50.     for x=1,fieldsizex-1 do --collect accross the field
  51.         moveCollect()
  52.     end
  53.    
  54.    
  55.    
  56.     if y==fieldsizey then --we are done, so we need to go home
  57.         print "[!]Done farming!"
  58.  
  59.         turtle.turnRight()
  60.         for i=0,fieldsizey do turtle.forward() end
  61.         df = true
  62.         break
  63.     else -- we need to hook left and make another run
  64.         turtle.turnLeft()
  65.         moveCollect()
  66.         turtle.turnLeft()
  67.     end
  68.  
  69. end
  70.  
  71.  
  72. --dump items
  73. print "[!]Dumping items..."
  74. for i=1,16 do --go through each slot
  75.     turtle.select(i)
  76.     count = turtle.getItemCount() --count the items in each slot
  77.     if count ~= 0 then
  78.         turtle.dropDown(count) --if there are any dump them into the chest
  79.     end
  80. end
  81.  
  82. --refuel
  83. print "[!]Checking if I need fuel..."
  84. i = 1
  85. print(" - Fuel " .. turtle.getFuelLevel())
  86. while turtle.getFuelLevel() < minfuel do
  87.     if turtle.suck(1) == false then --theres no more in the chest!!!
  88.         print "[!]The fuel chest is out of fuel!!!"
  89.         break
  90.     end
  91.     turtle.refuel(1)
  92.  
  93.     i = i+1
  94.     if math.fmod(i,10) == 0 then
  95.         print(" - Fuel " .. turtle.getFuelLevel())
  96.     end
  97.     end
  98.     print "[!]Done refueling!"
  99.  
  100.     turtle.turnRight()
  101.     turtle.turnRight()
  102.    
  103.     waitFourMinutes()
  104.  
  105.     while rs.getAnalogSignal("left") < 1 do
  106.         print "[!] Request signal not high enough"
  107.         waitFourMinutes()
  108.     end
  109. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement