-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwheatfarm.lua
More file actions
167 lines (144 loc) · 3.74 KB
/
wheatfarm.lua
File metadata and controls
167 lines (144 loc) · 3.74 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
local fullstacks = true
local bmcDirection = 4 --bone meal chest direction
local scDirection = 3 -- seed chest direction
local depositDirection = 2 -- output direction
local facing = 1
local chestslot = 14
local seedslot = 15
local bonemealslot = 16
local function TurnRight()
facing = facing + 1
if facing > 4 then
facing = 1
end
turtle.turnRight()
end
function FindDirt()
local facingchest = true
turtle.select(chestslot)
facingchest = turtle.compare()
while facingchest do
turtle.turnRight()
turtle.select(chestslot)
facingchest = turtle.compare()
end
facing = 1
end
function SelectEmptySlot()
for n = 1, 13 do
if turtle.getItemCount(n) == 0 then
turtle.select(n)
break;
end
end
end
function SelectSeedSlot()
turtle.select(seedslot)
end
function CheckEmptySlots()
local emptySlots = false
for n = 1, 13 do
if turtle.getItemCount(n) == 0 then
emptySlots = true
break;
end
end
if not emptySlots then
Deposit()
end
end
function P(text)
term.clear()
term.setCursorPos(1, 1)
print(text)
end
function GetMoreSeeds()
P("Stocking seeds")
while facing ~= scDirection do
TurnRight()
end
turtle.select(seedslot)
turtle.suck()
end
function GetMoreBM()
P("Stocking bone meal")
while facing ~= bmcDirection do
TurnRight()
end
turtle.select(bonemealslot)
if turtle.suck() then
return true
else
return false
end
end
function Deposit()
P("Depositing yield")
while facing ~= depositDirection do
TurnRight()
end
for n=1,13 do
turtle.select(seedslot)
if not turtle.compareTo(n) then
turtle.select(n)
turtle.drop()
end
end
while facing ~= scDirection do
TurnRight()
end
for n=1,13 do
turtle.select(n)
turtle.drop()
end
end
function CheckSupplies()
local supplies = true
if turtle.getItemCount(seedslot) == 0 then
GetMoreSeeds()
end
if turtle.getItemCount(bonemealslot) == 0 then
supplies = GetMoreBM()
if not supplies then
waitforBM()
end
end
end
function waitforBM()
P("Waiting on more bone meal")
local continue = true
while facing ~= bmcDirection do
TurnRight()
end
while continue do
turtle.select(bonemealslot)
if turtle.suck() then
continue = false
else
sleep(30)
end
end
end
function Farm()
local continue = true
while continue do
FindDirt()
CheckSupplies()
P("Starting farm")
FindDirt()
CheckEmptySlots()
FindDirt()
if fullstacks then
SelectSeedSlot()
else
SelectEmptySlot()
end
turtle.dig()
turtle.dig()
turtle.select(seedslot)
turtle.place()
turtle.select(bonemealslot)
turtle.place()
end
end
Farm()