@@ -91,7 +91,7 @@ function forward()
91
91
while not turtle .forward () do
92
92
while turtle .getFuelLevel () == 0 do
93
93
turtle .select (fuel_slot )
94
- if not turtle . refuel (1 ) then
94
+ if not refuel () then
95
95
print (" Need Fuel to move... Please add fuel to slot " .. fuel_slot )
96
96
sleep (5 )
97
97
end
@@ -103,7 +103,7 @@ function forward()
103
103
turtle .attack ()
104
104
sleep (forward_sleep_time )
105
105
print (" Blocked from going forward" )
106
- end
106
+ end
107
107
end
108
108
end
109
109
152
152
function checkSupplies (slot , quantity )
153
153
if turtle .getItemSpace (slot ) > 60 then
154
154
-- TODO: Don't steal from other named slots
155
- for i = 1 ,16 do
155
+ for i = 5 ,16 do
156
156
turtle .select (i )
157
157
if turtle .compareTo (slot ) then
158
158
turtle .transferTo (slot )
@@ -214,6 +214,42 @@ function goUp(count)
214
214
end
215
215
end
216
216
217
+
218
+ -- From Excavate2
219
+ function refuel ( ammount )
220
+ local fuelLevel = turtle .getFuelLevel ()
221
+ if fuelLevel == " unlimited" then
222
+ return true
223
+ end
224
+
225
+ local needed = ammount
226
+ if turtle .getFuelLevel () < needed then
227
+ local fueled = false
228
+ for n = 1 ,16 do
229
+ if turtle .getItemCount (n ) > 0 then
230
+ turtle .select (n )
231
+ if turtle .refuel (1 ) then
232
+ while turtle .getItemCount (n ) > 0 and turtle .getFuelLevel () < needed do
233
+ turtle .refuel (1 )
234
+ end
235
+ if turtle .getFuelLevel () >= needed then
236
+ turtle .select (1 )
237
+ return true
238
+ end
239
+ end
240
+ end
241
+ end
242
+ turtle .select (1 )
243
+ return false
244
+ end
245
+
246
+ return true
247
+ end
248
+
249
+
250
+
251
+
252
+ -- Actual main function
217
253
if isRunning then
218
254
219
255
print (" Place 4 stacks of wall building materials into slot " .. wall_slot .. " and others" )
@@ -255,7 +291,10 @@ if isRunning then
255
291
sleep (1 )
256
292
end
257
293
end
258
- print (" Starting" )
294
+ print (" Fuel Level: [" .. turtle .getFuelLevel () .. " ] " )
295
+ print (" Starting Floor Pass" )
296
+
297
+ -- Begin Floor
259
298
turtle .turnLeft ()
260
299
doFloor ()
261
300
doCorner (4 ,doWall )
@@ -293,10 +332,12 @@ if isRunning then
293
332
294
333
nextLoop ()
295
334
296
-
297
335
dig ()
298
336
299
337
placeDown (floor_slot )
338
+ -- end floor
339
+
340
+
300
341
301
342
goUp (1 )
302
343
turtle .select (torch_slot )
@@ -310,7 +351,11 @@ if isRunning then
310
351
forward ()
311
352
turtle .turnLeft ()
312
353
turtle .turnLeft ()
313
-
354
+
355
+ print (" Fuel Level: [" .. turtle .getFuelLevel () .. " ] " )
356
+ print (" Starting Wall Pass" )
357
+
358
+ -- begin Wall pass 1
314
359
turtle .turnLeft ()
315
360
doAir ()
316
361
doCorner (4 ,doWall )
@@ -350,9 +395,14 @@ if isRunning then
350
395
351
396
nextLoop ()
352
397
dig ()
398
+ -- end wall pass 1
399
+
353
400
354
401
goUp (3 )
355
-
402
+
403
+ print (" Fuel Level: [" .. turtle .getFuelLevel () .. " ] " )
404
+ print (" Starting Ceiling pass" )
405
+ -- Begin Ceiling
356
406
turtle .turnLeft ()
357
407
doCeiling ()
358
408
turtle .turnRight ()
@@ -397,7 +447,9 @@ if isRunning then
397
447
doCorner (4 ,doCeiling )
398
448
doCeiling ()
399
449
doCorner (4 ,doCeiling )
400
-
450
+ -- end ceiling
451
+
452
+ -- return to original position
401
453
turtle .turnLeft ()
402
454
forward ()
403
455
turtle .turnRight ()
@@ -410,4 +462,7 @@ if isRunning then
410
462
turtle .down ()
411
463
turtle .down ()
412
464
turtle .forward ()
465
+
466
+ print (" Fuel Level: [" .. turtle .getFuelLevel () .. " ] " )
467
+
413
468
end
0 commit comments