SHOW:
|
|
- or go back to the newest paste.
| 1 | function farm (xLength, yLength) | |
| 2 | for x = 1, xLength, 1 do | |
| 3 | for y = 1, yLength, 1 do | |
| 4 | nineXNine(9,9) | |
| 5 | if y ~= yLength then | |
| 6 | goToNextJobY() | |
| 7 | end | |
| 8 | end | |
| 9 | if x ~= xLength then | |
| 10 | goToNextJobX(yLength) | |
| 11 | end | |
| 12 | end | |
| 13 | goHomeBig(xLength, yLength) | |
| 14 | end | |
| 15 | ||
| 16 | function goToNextJobX(yLength) | |
| 17 | turtle.turnRight() | |
| 18 | turtle.turnRight() | |
| 19 | - | goForward(((yLength-1)*10)-1) |
| 19 | + | goForward((yLength-1)*10) |
| 20 | turtle.turnLeft() | |
| 21 | goForward(10) | |
| 22 | turtle.turnRight() | |
| 23 | ||
| 24 | end | |
| 25 | ||
| 26 | function goToNextJobY() | |
| 27 | goForward(10) | |
| 28 | end | |
| 29 | ||
| 30 | function goHomeBig(xLength, yLength) | |
| 31 | turtle.turnRight() | |
| 32 | turtle.turnRight() | |
| 33 | turtle.turnRight() | |
| 34 | turtle.turnRight() | |
| 35 | end | |
| 36 | ||
| 37 | function nineXNine(targetLength, targetWidth) | |
| 38 | ||
| 39 | for width = 1, targetWidth, 1 do | |
| 40 | processLine(targetLength) | |
| 41 | ||
| 42 | if width == targetWidth then | |
| 43 | goHome(targetLength, targetWidth) | |
| 44 | elseif width%2 == 1 then | |
| 45 | turnRight() | |
| 46 | nextMoveIsRight = false | |
| 47 | else | |
| 48 | turnLeft() | |
| 49 | nextMoveIsRight = true | |
| 50 | end | |
| 51 | end | |
| 52 | end | |
| 53 | ||
| 54 | function processLine(targetLength) | |
| 55 | doWork() | |
| 56 | for length = 1, targetLength-1, 1 do | |
| 57 | turtle.forward() | |
| 58 | doWork() | |
| 59 | end | |
| 60 | end | |
| 61 | ||
| 62 | function doWork() | |
| 63 | selectSeeds() | |
| 64 | turtle.digDown() | |
| 65 | turtle.placeDown() | |
| 66 | end | |
| 67 | ||
| 68 | function selectSeeds() | |
| 69 | data = turtle.getItemDetail() | |
| 70 | print("Item name: ", data.name)
| |
| 71 | end | |
| 72 | ||
| 73 | function turnRight() | |
| 74 | turtle.turnRight() | |
| 75 | turtle.forward() | |
| 76 | turtle.turnRight() | |
| 77 | end | |
| 78 | ||
| 79 | function turnLeft() | |
| 80 | turtle.turnLeft() | |
| 81 | turtle.forward() | |
| 82 | turtle.turnLeft() | |
| 83 | end | |
| 84 | ||
| 85 | function turnAround() | |
| 86 | turtle.turnLeft() | |
| 87 | turtle.turnLeft() | |
| 88 | end | |
| 89 | ||
| 90 | function goForward(lengthToGo) | |
| 91 | for lengthWent = 1, lengthToGo, 1 do | |
| 92 | turtle.forward() | |
| 93 | end | |
| 94 | end | |
| 95 | ||
| 96 | function goHome(targetLength, targetWidth) | |
| 97 | if(targetWidth%2 == 1) then | |
| 98 | turnAround() | |
| 99 | goForward(targetLength-1) | |
| 100 | end | |
| 101 | ||
| 102 | turtle.turnRight() | |
| 103 | goForward(targetWidth-1) | |
| 104 | turtle.turnRight() | |
| 105 | end | |
| 106 | ||
| 107 | farm(3, 3) |