Facebook
From logleg, 1 Year ago, written in Lua.
This paste is a reply to lua mc from logleg - view diff
Embed
Download Paste or View Raw
Hits: 162
  1. local success, blockData
  2. local rows = 1;
  3.  
  4. while true do
  5.         scanCropField()
  6. }
  7.  
  8. function scanCropField()
  9.         moveAndHarvest()
  10.         rotateToNextRow()
  11. end
  12.  
  13. function rotateToNextRow()
  14.         if (rows % 2 == 0) then
  15.                 -- even number
  16.                 turtle.turnLeft()
  17.                 turtle.forward()
  18.                 turtle.forward()
  19.                 turtle.turnLeft()
  20.         else
  21.                 -- odd number
  22.                 turtle.turnRight()
  23.                 turtle.forward()
  24.                 turtle.turnRight()
  25.         end
  26.         rows = rows + 1
  27. end
  28.        
  29. function moveAndHarvest()
  30.         while not turtle.detect() do
  31.                 checkAndHarvestCrop()
  32.         end
  33. end
  34.  
  35. function checkAndHarvestCrop()
  36.         blockData = turtle.inspectDown()
  37.         if blockData.metadata == 7 then
  38.                 turtle.placeDown()
  39.                 turtle.suckDown()
  40.         end
  41.         turtle.forward()
  42. end