-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdigTunnels.lua
72 lines (63 loc) · 2.23 KB
/
digTunnels.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
-- VALUES FOR THE DIRECTIONS
local up = "up"
local down = "down"
local forward = "forward"
local back = "back"
local right = "right"
local left = "left"
-- ------------------------------------------------------------ --
-- START OF THE CODE THAT GETS EXECUTED WHEN THE PROGRAM STARTS --
-- ------------------------------------------------------------ --
-- LOAD FUNCTIONS FROM THE OTHER FILES
os.loadAPI("api_digTunnels")
os.loadAPI("api_sharedFunctions")
os.loadAPI("api_turtleExt")
-- GET THE CONFIGURATION OF THE PROGRAM
local args={...}
local configuration = api_sharedFunctions.getConfig("config", args)
if configuration == nil then
return
end
-- USED TO KEEP TRACK OF THE CURRENT POSITION
configuration.currentL = 1
configuration.currentT = 1
configuration.currentS = 0
-- CHECK THE MINIMAL FUEL VALUE SPECIFIED BY THE USER
if (configuration.departureFuel < 400) then
print("Warning: Low fuel value chosen")
print("Do you wish to proceed? (Y/N)")
local answer=io.read()
if not (answer=="Y") then
return
end
end
-- RESTOCK THE TURTLE
api_sharedFunctions.dropoffAndRestock(configuration, 0, false, true, true)
-- FOR EVERY LEVEL
for curL = 1 + configuration.skipL, configuration.numL do
local firstT = 1
if curL == 1 + configuration.skipL then
firstT = firstT + configuration.skipT
end
-- FOR EVERY TUNNEL
for curT = firstT, configuration.numT do
local firstS = 0
if (curL == 1 + configuration.skipL) and (curT == 1 + configuration.skipT) and (configuration.skipS~=0) then
firstS = 1 + configuration.skipS
end
-- FOR EVERY SHAFT
for curS = firstS, configuration.numS do
api_sharedFunctions.moveToLocation(configuration, curL, curT, curS)
api_digTunnels.digSegment(configuration)
if api_sharedFunctions.needsRestocking(configuration) then
api_sharedFunctions.dropoffAndRestock(configuration, 0, false, false, false)
end
end
end
end
-- RETURN TO START AND DROPOFF
api_sharedFunctions.moveToLocation(configuration, 1, 1, 0)
api_sharedFunctions.dropoff(configuration, 0, true, true)
-- ---------------------------------------------------------- --
-- END OF THE CODE THAT GETS EXECUTED WHEN THE PROGRAM STARTS --
-- ---------------------------------------------------------- --