View difference between Paste ID: wvgpsTJQ and sPwKrheM
SHOW: | | - or go back to the newest paste.
1
local args = {...}
2
--slot id:
3
--1 = mining well, 2=tesseract wtih shiny dust, 3 pipes
4
print("Dont forget to shiny dust the tesseract to retain their setting upon destroy");
5
function unloadSystems()
6-
placeAt(0,0,0,1);--well
6+
turtle.up();
7-
turnRight();
7+
turtle.up();
8-
placeAt(0,0,0,1);--well
8+
turtle.select(2);
9-
turnLeft();
9+
turtle.place();
10-
turnLeft();
10+
turtle.down();
11-
placeAt(0,0,0,1);--well
11+
12
turtle.place();
13-
placeAt(1,0,0,2);  --pipe
13+
14-
turnRight();
14+
15-
placeAt(1,0,0,3);--tesseract
15+
16-
turnRight();
16+
17-
placeAt(1,0,0,2);--pipe
17+
18-
goToCord(0,0,0);
18+
19-
placeUpAt(0,0,0,2);--pipe
19+
20
                turtle.select(i);
21
           until turtle.dropUp();                
22-
function loadSystems()
22+
23-
goToCord(0,0,0);
23+
24
  end
25-
turtle.dig(); -- well
25+
26-
turnRight();
26+
27-
turtle.dig(); -- well
27+
28-
turnLeft();
28+
29-
turnLeft();
29+
30-
turtle.dig(); --well
30+
31-
turtle.digUp()--pipe
31+
32
end
33-
goToCord(1,0,0);
33+
34-
turtle.dig();--pipe
34+
35-
turnRight();
35+
36-
turtle.dig();--tesseract
36+
37-
turnRight();--pipe
37+
38
local currentZ=0 -- depth
39-
goToCord(0,0,0);
39+
40-
turnLeft();
40+
41
function place(slotID)
42
                zz.select(slotID)
43
                if zz.getItemCount()>0 then
44-
  if i ~=2 then 
44+
45
                end
46
     return false
47
end
48
function placeUp(slotID)
49-
           until turtle.drop() or turtle.dropDown();                
49+
50
                if zz.getItemCount()>0 then
51
                        return zz.placeUp()
52-
   end
52+
53
     return false
54
end
55
function refuel(amount)
56
        while zz.getFuelLevel()<=math.abs(amount) do
57
                zz.select(16)
58
                zz.refuel(1)
59
                                print("Refueling")
60
        end
61
end
62
function turnRight()
63
        while zz.turnRight() do
64
                currRad=(currRad-1)%4
65
                break
66
        end
67
end
68
function turnLeft()
69
        while zz.turnLeft() do
70
                currRad=(currRad+1)%4
71
                break
72
        end
73
end
74
function turnToRad(r)
75
        if currRad==r then
76
                return true
77
        end
78
        while currRad~=r do
79
                if currRad>r then
80
                        turnRight()
81
                elseif currRad<r then
82
                        turnLeft()
83
                end
84
        end
85
end
86
function alertForProblem(stringCauseOfProblem)
87
        zz.turnRight()
88
        zz.turnRight()
89
        zz.turnRight()
90
        zz.turnRight()
91
        print(stringCauseOfProblem)
92
end
93
function moveByX(ox)
94
        local x=currentX+ox
95
        turnToRad(0)
96
        refuel(ox)
97
        while ox~=0 do
98
                if ox<0 then
99
                        if zz.back() then
100
                                ox=ox+1
101
                                currentX=currentX-1
102
                        else
103
                                alertForProblem("can not move - check fuel or obstacle")
104
                                moveByX(ox)
105
                                break
106
                        end
107
                else
108
                        if zz.forward() then
109
                                ox=ox-1
110
                                currentX=currentX+1
111
                        else
112
                                alertForProblem("can not move - check fuel or obstacle")
113
                                moveByX(ox)
114
                                break
115
                        end
116
                end
117
        end
118
end
119
function moveByZ(oz)
120
        local z=currentZ+oz
121
        turnToRad(1)
122
        refuel(oz)
123
        while oz~=0 do
124
                if oz<0 then
125
                        if zz.back() then
126
                                oz=oz+1
127
                                currentZ=currentZ-1
128
                        else
129
                                alertForProblem("can not move - check fuel or obstacle")
130
                                moveByZ(oz)
131
                                break
132
                        end
133
                else
134
                        if zz.forward() then
135
                                oz=oz-1
136
                                currentZ=currentZ+1
137
                        else
138
                                alertForProblem("can not move - check fuel or obstacle")
139
                                moveByZ(oz)
140
                                break
141
                        end
142
                end
143
        end
144
end
145
function moveByY(oy)
146
        local y=currentY+oy
147
        refuel(oy)
148
        while oy~=0 do
149
                if oy<0 then
150
                        if zz.down() then
151
                                oy=oy+1
152
                                currentY=currentY-1
153
                        else
154
                                alertForProblem("can not move down - check fuel or obstacle")
155
                                moveByY(oy)
156
                                break
157
                        end
158
                else
159
                        if zz.up() then
160
                                oy=oy-1
161
                                currentY=currentY+1
162
                        else
163
                                alertForProblem("can not move up - check fuel or obstacle")
164
                                moveByY(oy)
165
                                break
166
                        end
167
                end
168
        end
169
end
170
function goToCord(y,x,z)
171
        local differenceX=x-(currentX)
172
        local differenceY=y-currentY
173
        local differenceZ=z-currentZ
174
        if differenceX~=0 then moveByX(differenceX) end
175
        if differenceY~=0 then moveByY(differenceY) end
176
        if differenceZ~=0 then moveByZ(differenceZ) end
177
end
178
function placeAt(y,x,z,slotID)
179
        goToCord(y,x,z)
180
        if place(slotID) then return true
181
        else
182
                alertForProblem("can not place ahead - must be air ahead or do I have a material to place")
183
                placeAt(y,x,z,slotID)
184
        end
185
end
186
function placeUpAt(y,x,z,slotID)
187
        goToCord(y,x,z)
188
        if placeUp(slotID) then return true
189
        else
190
                alertForProblem("can not place up - must be air ahead or do I have a material to place")
191
                placeUpAt(y,x,z,slotID)
192
        end
193
end
194
local repeatUntil=1;
195
if (#args==1) and tonumber(args[1])>1 then
196
repeatUntil=tonumber(args[1]);
197
end
198
for zd=1,repeatUntil do
199
  unloadSystems()
200
os.sleep(1);
201
  repeat
202
 
203
  until not isStillWorking();
204
  dumpAllItems();
205
  turtle.select(1);
206
   turtle.dig();
207
turtle.up();
208
turtle.select(2);
209
turtle.dig();
210
turtle.down();
211
turtle.down();
212
 
213
  if repeatUntil>1 then
214
    turtle.forward();
215
  end
216
end
217
print("done");