-
Notifications
You must be signed in to change notification settings - Fork 0
/
certus.lua
118 lines (107 loc) · 2.81 KB
/
certus.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
length=5
width=5
function sel(name)
i=1
found=false
while(i<=4*4)do
turtle.select(i)
detail=turtle.getItemDetail()
if((not(detail==nil)) and detail.name==name)then
found=true
break
end
i=i+1
end
return found
end
while (true) do
x=0
y=0
dx=1
dy=1
m=0
b=false
print('(x,y), (dx,dy), (b,t))')
while((dx>0 or x>=0) and (dx<0 or x<width)) do
while((dy>0 or y>0) and (dy<0 or y<length)) do
print('(',x,',',y,'), (',dx,',',dy,'), (', b, ',',t,')')
-- inspect crystal
solid,obj=turtle.inspectDown()
if(force or solid) then
-- mine crystal
if(obj.name=='ae2:quartz_cluster') then
turtle.digDown()
m=m+1
end
end
solid,obj=turtle.inspectDown()
if(not solid) then
-- check depleted budding block
turtle.down()
solid,obj=turtle.inspectDown()
if((solid and obj.name=='ae2:quartz_block') or not solid)then
-- replace depleted budding block with new, if possible
if(solid)then
turtle.digDown()
end
if (sel('ae2:flawed_budding_quartz'))then
turtle.placeDown()
end
end
turtle.up()
end
y=y+dy
if(y>=length)then
if(b)then
t=turtle.turnLeft
it=turtle.turnRight
else
t=turtle.turnRight
it=turtle.turnLeft
end
elseif(y<=0)then
if(b)then
t=turtle.turnRight
it=turtle.turnLeft
else
t=turtle.turnLeft
it=turtle.turnRight
end
end
if(t==nil and ((dy>0 or y>0) and (dy<0 or y<length)))then
turtle.forward()
end
end
if (t==nil)then
print('error: turn action must not be nil here')
exit()
end
x=x+dx
dy=dy*-1
if (force) then
force=false
elseif (m==0) then
force=true
end
if ((dx>0 or x>=0) and (dx<0 or x<width))then
ut=t
inv=false
else
ut=it
x=x+(dx*2)
inv=true
end
ut()
if(not inv) then
turtle.forward()
end
ut()
t=nil
if(inv)then
--todo: Refill code here
os.sleep(5)
end
end
dx=dx*-1
b =not b
end