SHOW:
|
|
- or go back to the newest paste.
1 | - | farmLength = 25 |
1 | + | farmLength = 19 |
2 | - | farmWidth = 16 |
2 | + | farmWidth = 8 |
3 | - | |
3 | + | |
4 | function fuel() | |
5 | if turtle.getFuelLevel() < 1 then | |
6 | turtle.select(1) | |
7 | turtle.refuel(1) | |
8 | end | |
9 | end | |
10 | - | |
10 | + | |
11 | function move(d, n) | |
12 | n = n or 1 | |
13 | for i=1,n do | |
14 | fuel() | |
15 | d() | |
16 | end | |
17 | end | |
18 | - | |
18 | + | |
19 | function harvest() | |
20 | - | turtle.digDown() |
20 | + | local success, data = turtle.inspectDown() |
21 | - | turtle.select(2) |
21 | + | if success then |
22 | - | if turtle.getItemCount() > 1 then |
22 | + | if data.state.age == 7 then |
23 | - | turtle.placeDown() |
23 | + | turtle.digDown() |
24 | turtle.select(2) | |
25 | if turtle.getItemCount() > 1 then | |
26 | - | |
26 | + | turtle.placeDown() |
27 | end | |
28 | end | |
29 | end | |
30 | end | |
31 | ||
32 | function harvestRow() | |
33 | harvest() | |
34 | - | |
34 | + | |
35 | move(turtle.forward) | |
36 | harvest() | |
37 | end | |
38 | end | |
39 | - | |
39 | + | |
40 | - | move(turtle.forward) |
40 | + | |
41 | - | for row=1, farmWidth do |
41 | + | |
42 | - | harvestRow() |
42 | + | |
43 | - | if row < farmWidth then |
43 | + | |
44 | - | turnAround[row % 2]() |
44 | + | |
45 | function run() | |
46 | - | turnAround[row % 2]() |
46 | + | move(turtle.forward) |
47 | for row=1, farmWidth do | |
48 | harvestRow() | |
49 | - | turtle.turnRight() |
49 | + | if row < farmWidth then |
50 | - | move(turtle.forward,farmWidth-1) |
50 | + | turnAround[row % 2]() |
51 | - | turtle.turnRight() |
51 | + | move(turtle.forward) |
52 | - | move(turtle.back) |
52 | + | turnAround[row % 2]() |
53 | - | |
53 | + | elseif row % 2 == 1 then |
54 | - | for i=3,16 do |
54 | + | turtle.turnRight() |
55 | - | turtle.select(i) |
55 | + | turtle.turnRight() |
56 | - | turtle.dropDown() |
56 | + | move(turtle.forward,farmLength-1) |
57 | end | |
58 | end | |
59 | turtle.turnRight() | |
60 | move(turtle.forward,farmWidth-1) | |
61 | turtle.turnRight() | |
62 | move(turtle.back) | |
63 | ||
64 | for i=3,16 do | |
65 | turtle.select(i) | |
66 | turtle.dropDown() | |
67 | end | |
68 | end | |
69 | ||
70 | local alarm = os.setAlarm(5) | |
71 | while true do | |
72 | local evt, arg = os.pullEvent("alarm") | |
73 | if arg == alarm then | |
74 | run() | |
75 | end | |
76 | end |