-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfarmMeal.lua
More file actions
112 lines (97 loc) · 1.46 KB
/
farmMeal.lua
File metadata and controls
112 lines (97 loc) · 1.46 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
-- By Roachy
waitCycle = 1
waitRestock = 10
slotMealComp = 1
slotMeal = 2
slotSeed = 3
local function tryDigDown()
while turtle.detectDown() do
if turtle.digDown() then
sleep(0.5)
else
return false
end
end
return true
end
local function tryUp()
while not turtle.up() do
if turtle.detectUp() then
if not tryDigUp() then
return false
end
elseif turtle.attackUp() then
else
sleep( 0.5 )
end
end
return true
end
local function tryDown()
while not turtle.down() do
if turtle.detectDown() then
if not tryDigDown() then
return false
end
elseif turtle.attackDown() then
else
sleep( 0.5 )
end
end
return true
end
function plant()
turtle.select(slotSeed)
turtle.placeDown()
end
function grow()
turtle.select(slotMeal)
turtle.placeDown()
end
function harvest()
turtle.select(slotSeed)
tryDigDown()
end
function getMeal()
tryDown()
turtle.select(slotMeal)
turtle.dropDown()
turtle.suck()
tryUp()
end
function dump()
for i = 4, 16 do
turtle.select(i)
turtle.drop()
end
end
function full()
if turtle.getItemCount(16) > 0 then
return true
end
return false
end
function needMeal()
turtle.select(slotMeal)
if(turtle.compareTo(slotMealComp)) then
return false
end
return true
end
while true do
if(redstone.getInput('left')) then
sleep(waitCycle)
while(needMeal()) do
getMeal()
sleep(waitRestock)
end
if(full()) then
dump()
end
plant()
grow()
harvest()
else
sleep(5)
end
end