-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmine.lua
73 lines (60 loc) · 1.06 KB
/
mine.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
local arg = {...}
local rowLength = arg[1]
local blockNum = arg[2]
local TORCH_SLOT = 1
function layTorch()
turtle.select(TORCH_SLOT)
turtle.placeDown()
end
function digAll()
turtle.digUp()
while turtle.detect() do
turtle.dig()
sleep(0.8)
end
turtle.digDown()
end
function clearRow(length)
for i = 1, length, 1 do
digAll()
turtle.forward()
end
end
function rightTurn()
turtle.turnRight()
digAll()
turtle.forward()
turtle.turnRight()
end
function leftTurn()
turtle.turnLeft()
digAll()
turtle.forward()
turtle.turnLeft()
end
function mine(rowLength, blockNum)
for i = 1, blockNum, 1 do
if i > 1 then
leftTurn()
end
for j = 1, rowLength, 1 do
digAll()
if i % 2 == 1 and j % 5 == 0 then
layTorch()
end
turtle.forward()
end
rightTurn()
for j = 1, rowLength, 1 do
digAll()
turtle.forward()
end
end
-- Return home.
turtle.turnRight()
for i = 1, blockNum * 2, 1 do
turtle.forward()
end
turtle.turnRight()
end
mine(rowLength, blockNum)