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 |
5 | + | if y ~= yLength then |
6 | goToNextJobY() | |
7 | end | |
8 | end | |
9 | - | if x != xLength then |
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) | |
20 | turtle.turnRight() | |
21 | goForward(10) | |
22 | turtle.turnLeft() | |
23 | end | |
24 | ||
25 | function goToNextJobY() | |
26 | goForward(10) | |
27 | end | |
28 | ||
29 | function goHomeBig(xLength, yLength) | |
30 | turtle.turnRight() | |
31 | turtle.turnRight() | |
32 | turtle.turnRight() | |
33 | turtle.turnRight() | |
34 | end | |
35 | ||
36 | function nineXNine(targetLength, targetWidth) | |
37 | ||
38 | for width = 1, targetWidth, 1 do | |
39 | processLine(targetLength) | |
40 | ||
41 | if width == targetWidth then | |
42 | goHome(targetLength, targetWidth) | |
43 | elseif width%2 == 1 then | |
44 | turnRight() | |
45 | nextMoveIsRight = false | |
46 | else | |
47 | turnLeft() | |
48 | nextMoveIsRight = true | |
49 | end | |
50 | end | |
51 | end | |
52 | ||
53 | function processLine(targetLength) | |
54 | doWork() | |
55 | for length = 1, targetLength-1, 1 do | |
56 | turtle.forward() | |
57 | doWork() | |
58 | end | |
59 | end | |
60 | ||
61 | function doWork() | |
62 | turtle.digDown() | |
63 | turtle.placeDown() | |
64 | end | |
65 | ||
66 | function turnRight() | |
67 | turtle.turnRight() | |
68 | turtle.forward() | |
69 | turtle.turnRight() | |
70 | end | |
71 | ||
72 | function turnLeft() | |
73 | turtle.turnLeft() | |
74 | turtle.forward() | |
75 | turtle.turnLeft() | |
76 | end | |
77 | ||
78 | function turnAround() | |
79 | turtle.turnLeft() | |
80 | turtle.turnLeft() | |
81 | end | |
82 | ||
83 | function goForward(lengthToGo) | |
84 | for lengthWent = 1, lengthToGo, 1 do | |
85 | turtle.forward() | |
86 | end | |
87 | end | |
88 | ||
89 | function goHome(targetLength, targetWidth) | |
90 | if(targetWidth%2 == 1) then | |
91 | turnAround() | |
92 | goForward(targetLength-1) | |
93 | end | |
94 | ||
95 | turtle.turnRight() | |
96 | goForward(targetWidth-1) | |
97 | turtle.turnRight() | |
98 | end | |
99 | ||
100 | nineXNine(9, 9) |