forked from Starkus/quarry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
t.lua
170 lines (122 loc) · 2.39 KB
/
t.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
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
167
168
169
170
local MAXTRIES = 100
function turnAround()
local success = false
success = turtle.turnRight()
success = success and turtle.turnRight()
return success
end
function dig()
local tries = 0
while turtle.detect() do
local s, data = turtle.inspect()
if data.name == "minecraft:bedrock" then
printError("Hit bedrock forwards!")
return false
end
turtle.dig()
sleep(0.4)
tries = tries+1
if tries > MAXTRIES then
printError("Can't dig forward")
return false
end
end
return true
end
function digDown()
local tries = 0
while turtle.detectDown() do
local s, data = turtle.inspectDown()
if data.name == "minecraft:bedrock" then
printError("Hit bedrock below!")
return false
end
turtle.digDown()
sleep(0.4)
tries = tries+1
if tries > MAXTRIES then
printError("Can't dig down")
return false
end
end
return true
end
function digUp()
local tries = 0
while turtle.detectUp() do
local s, data = turtle.inspectUp()
if data.name == "minecraft:bedrock" then
printError("Hit bedrock above!")
return false
end
turtle.digUp()
sleep(0.4)
tries = tries+1
if tries > MAXTRIES then
printError("Can't dig up")
return false
end
end
return true
end
function fw(l)
l=l or 1
for i=1, l do
local tries = 0
while turtle.forward() ~= true do
turtle.dig()
turtle.attack()
sleep(0.2)
tries = tries+1
if tries > MAXTRIES then
printError("Can't move forward")
return false
end
end
end
return true
end
function up(l)
l=l or 1
for i=1, l do
local tries = 0
while turtle.up() ~= true do
turtle.digUp()
turtle.attackUp()
sleep(0.2)
tries = tries+1
if tries > MAXTRIES then
printError("Can't move up")
return false
end
end
end
return true
end
function down(l)
l=l or 1
for i=1, l do
local tries = 0
while turtle.down() ~= true do
turtle.digDown()
turtle.attackDown()
sleep(0.2)
tries = tries+1
if tries > MAXTRIES then
printError("Can't move down")
return false
end
end
end
return true
end
function back(l)
l=l or 1
for i=1, l do
if turtle.back() ~= true then
turnAround()
fw()
turnAround()
end
end
end