-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdig.lua
129 lines (120 loc) · 3.77 KB
/
dig.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
local tArgs = {...}
b = tArgs[1] % 2
function moveDown()
while turtle.down() == false do
turtle.attack()
end
end
function moveForward()
while turtle.forward() == false do
turtle.attack()
turtle.dig()
end
checkSpace()
end
function checkSpace()
if turtle.getItemCount(15) > 0 then
while turtle.detectUp() == true do
turtle.digUp()
turtle.detectUp()
end
while turtle.attackUp() == true do
turtle.attackUp()
end
turtle.select(16)
turtle.placeUp()
emptyInv()
turtle.select(16)
turtle.digUp()
turtle.select(1)
end
end
function emptyInv()
for i = 1, 15 do
turtle.select(i)
turtle.dropUp()
end
end
function digLayerOne()
local stripNum = 2
turtle.digDown()
moveDown()
turtle.digDown()
moveDown()
turtle.digDown()
for i = 1, tArgs[1] do
for i = 1, tArgs[1] - 1 do
turtle.dig()
moveForward()
turtle.digUp()
turtle.digDown()
end
if stripNum == tArgs[1] + 1 then
turtle.turnRight()
turtle.turnRight()
moveDown()
break
elseif stripNum % 2 == 0 then
turtle.turnRight()
turtle.dig()
moveForward()
turtle.turnRight()
turtle.digUp()
turtle.digDown()
stripNum = stripNum + 1
elseif stripNum % 2 == 1 then
turtle.turnLeft()
turtle.dig()
moveForward()
turtle.turnLeft()
turtle.digUp()
turtle.digDown()
stripNum = stripNum + 1
end
end
end
function digLayerTwo()
local stripNum = 2
turtle.digDown()
moveDown()
turtle.digDown()
moveDown()
turtle.digDown()
for i = 1, tArgs[1] do
for i = 1, tArgs[1] - 1 do
turtle.dig()
moveForward()
turtle.digUp()
turtle.digDown()
end
if stripNum == tArgs[1] + 1 then
turtle.turnRight()
turtle.turnRight()
moveDown()
break
elseif stripNum % 2 == 1 then
turtle.turnRight()
turtle.dig()
moveForward()
turtle.turnRight()
turtle.digUp()
turtle.digDown()
stripNum = stripNum + 1
elseif stripNum % 2 == 0 then
turtle.turnLeft()
turtle.dig()
moveForward()
turtle.turnLeft()
turtle.digUp()
turtle.digDown()
stripNum = stripNum + 1
end
end
end
while b == 1 do
digLayerOne()
end
while b == 0 do
digLayerOne()
digLayerTwo()
end