-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathharvest.lua
More file actions
67 lines (63 loc) · 1.42 KB
/
harvest.lua
File metadata and controls
67 lines (63 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
moves = 9 --side length of farmland
function tryHarvest()
local b, v = turtle.inspectDown()
if b and v.metadata == 7 then
turtle.digDown()
end
turtle.placeDown()
end
function depositChest()
for i=2,16 do
turtle.select(i)
turtle.dropDown()
end
turtle.select(1)
end
function farm ()
for i = 0, moves-1 do
local j = 0
while j <= moves-1 do
local res = turtle.forward()
if not res then
turtle.up()
turtle.forward()
turtle.forward()
turtle.down()
j = j + 1
end
tryHarvest()
j = j + 1
end
if i ~= moves-1 then
if i%2==0 then
turtle.turnRight()
turtle.forward()
turtle.turnRight()
else
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
end
end
tryHarvest()
end
if moves%2==0 then
turtle.turnRight()
for i=0, moves-2 do
turtle.forward()
end
else
turtle.turnRight()
turtle.turnRight()
for i=0, moves-1 do
turtle.forward()
end
turtle.turnRight()
for i=0, moves-2 do
turtle.forward()
end
end
turtle.turnRight()
depositChest()
end
farm()