-
Notifications
You must be signed in to change notification settings - Fork 0
/
remine_3x3.lua
104 lines (96 loc) · 2.12 KB
/
remine_3x3.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
local args = {...}
local home_pos = {gps.locate()}
local main_line_pos = {gps.locate()}
local instant_pos = {gps.locate()}
function move_front ()
turtle.dig()
while (not turtle.forward()) do
turtle.dig()
end
turtle.digDown()
turtle.digUp()
end
function half_turn ()
turtle.turnRight()
turtle.turnRight()
end
function move_front_3x3 ()
move_front()
turtle.turnLeft()
move_front()
half_turn()
turtle.forward()
move_front()
half_turn()
turtle.forward()
turtle.turnRight()
end
function unload_inventory ()
while (turtle.forward()) do
end
for i = 1, 16 do
turtle.select(i)
turtle.drop(64)
end
turtle.select(1)
half_turn()
end
function mining (distance)
for i = 1, distance do
move_front_3x3()
if i%10 == 0 then
turtle.placeDown()
end
end
half_turn()
for j = 1, distance do
turtle.forward()
end
return (true);
end
function search_line ()
i = tonumber(args[1])
j = 0
while (j ~= i) do
turtle.forward()
if (turtle.detectDown()) then
j = j + 1
end
end
main_line_pos = {gps.locate()}
end
function refill ()
turtle.turnLeft()
turtle.suck(64)
turtle.refuel()
turtle.turnLeft()
turtle.drop(64)
turtle.turnLeft()
turtle.suck(64)
turtle.turnLeft()
end
refill()
search_line()
turtle.turnLeft()
while (turtle.forward()) do
end
mining(30)
instant_pos = {gps.locate()}
while ((instant_pos[1] ~= main_line_pos[1]) or (instant_pos[3] ~= main_line_pos[3])) do
--print("x = ", instant_pos[1], " == ", main_line_pos[1])
--print("z = ", instant_pos[3], " == ", main_line_pos[3])
turtle.forward()
instant_pos = {gps.locate()}
end
while (turtle.forward()) do
end
mining(30)
instant_pos = {gps.locate()}
while ((instant_pos[1] ~= main_line_pos[1]) or (instant_pos[3] ~= main_line_pos[3])) do
--print("x = ", instant_pos[1], " == ", main_line_pos[1])
--print("z = ", instant_pos[3], " == ", main_line_pos[3])
turtle.forward()
instant_pos = {gps.locate()}
end
turtle.turnLeft()
unload_inventory()