StefanMermans

CC simple farm

Feb 28th, 2021 (edited)
553
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shouldGoLeft = true
  2. loops = 0
  3.  
  4. print("starting in 10 seconds")
  5. sleep(10)
  6.  
  7. function turnLeft()
  8.   turtle.turnLeft()
  9.   turtle.forward()
  10.   turtle.turnLeft()
  11. end
  12.  
  13. function turnRight()
  14.   turtle.turnRight()
  15.   turtle.forward()
  16.   turtle.turnRight()
  17. end
  18.  
  19. function isGrown(blockInfo)
  20.   return blockInfo.state.age == 3
  21. end
  22.  
  23. function goHome()
  24.   print("going home")
  25.   turtle.turnLeft()
  26.   i = 0
  27.   while (i < 17) do
  28.     i = i + 1
  29.     turtle.forward()
  30.   end
  31.   turtle.turnLeft()
  32.   print("sleeping...")
  33.   sleep(600)
  34.   print("starting!")
  35.   loops = 0
  36.   shouldGoLeft = true
  37. end
  38.  
  39. function placeSeeds()
  40.   digged, reason = turtle.digDown()
  41.   if (digged == false) then
  42.     print(reason)
  43.   end
  44.  
  45.   placed, reason = turtle.placeDown()
  46.   if (placed == false) then
  47.     print(reason)
  48.   end
  49.  
  50.   while (true) do
  51.     pickedUp, _ = turtle.suckDown()
  52.     if (pickedUp == false) then
  53.       break
  54.     end
  55.   end
  56. end
  57.  
  58. function farmBlock()
  59.   hasBlock, blockInfo = turtle.inspectDown()
  60.   if hasBlock then
  61.     if isGrown(blockInfo) then
  62.       placeSeeds()
  63.     end
  64.   else
  65.     placeSeeds()
  66.   end
  67. end
  68.  
  69. while (true) do
  70.   i = 0
  71.   while (i < 9) do
  72.     turtle.forward()
  73.     farmBlock()  
  74.  
  75.     i = i+1
  76.   end
  77.  
  78.   loops = loops + 1
  79.  
  80.   if (loops == 18) then
  81.     goHome()
  82.   elseif (shouldGoLeft) then
  83.     shouldGoLeft = false
  84.     turnLeft()
  85.   else
  86.     shouldGoLeft = true
  87.     turnRight()
  88.   end
  89. end
  90.  
RAW Paste Data