-
Notifications
You must be signed in to change notification settings - Fork 1
/
rminer
100 lines (88 loc) · 1.45 KB
/
rminer
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
function forward()
turtle.dig()
if turtle.forward() then
turtle.digUp()
return true
end
return false
end
function refuel()
print("refuel")
for i=1,16 do
turtle.select(i)
turtle.refuel()
end
end
function dummy()
print("forward")
end
function fill()
s = {}
for i=1, 10 do
s[i] = forward
end
return s
end
function also(s, f, r)
i = 0
for o=1,10 do
i = i + 1
if i == r then
print(".")
s[o] = f
i = 0
end
end
return s
end
function main ()
s = fill()
print(s)
s = also(s, refuel, 9)
print(s)
s = also(s, cleanup,8)
s = also(s, inventory, 5)
print(s)
for i=1,10 do
print(s[i])
s[i]()
end
end
function turn()
turtle.turnLeft()
turtle.turnLeft()
end
function cleanup()
for i=1,16 do
item = turtle.getItemDetail(i)
if item then
print(item.name)
if item.name == "minecraft:cobblestone" or item.name == "minecraft:dirt" or item.name == "minecraft:gravel" then
turtle.select(i)
turtle.drop()
end
end
end
end
function go()
for i=1,10 do
main()
end
end
function inventory()
master = rednet.lookup("master")
print(master)
for i=1,16 do
item = turtle.getItemDetail(i)
if item then
print(item.name)
rednet.send(master, item, "reporting")
if not rednet.receive("reporting", 10) then
turn()
end
end
end
end
turtle.refuel()
rednet.open("right")
inventory()