-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfarmer.lua
72 lines (59 loc) · 1.24 KB
/
farmer.lua
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
68
69
70
71
72
function harvest()
a, plant = turtle.inspectDown()
if a then
plantAge = plant.state.age
matureAge = 7
if plant.name == "minecraft:beetroots" then
matureAge = 3
end
if plantAge == matureAge then
print("It's ready!")
turtle.digDown()
turtle.placeDown()
else
print("Not ready")
end
else
turtle.placeDown()
end
end
function newRow()
if lastTurn == "left" then
turtle.turnRight()
free = turtle.forward()
if free == true then
turtle.turnRight()
lastTurn = "right"
else
turtle.turnRight()
lastTurn="left"
end
else
turtle.turnLeft()
free = turtle.forward()
if free == true then
turtle.turnLeft()
lastTurn = "left"
else
turtle.turnLeft()
lastTurn = "right"
end
end
end
function checkAndMove()
if turtle.detect() then
newRow()
end
end
function doMove()
harvest()
checkAndMove()
harvest()
checkAndMove()
turtle.forward()
end
--Above is for reference
lastTurn = "right"
while true do
doMove()
end