-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbranch_mine
43 lines (35 loc) · 1.22 KB
/
branch_mine
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
local argv = {...}
local branch_count = argv[1] or 2
local branch_length = argv[2] or 8
local branch_torch_distance = argv[3] or 9
-- Constants
local torch_slot = 1
local main_adit_width = 3
local main_adit_length = branch_count * 4
-- Figure out how many torches we need
local required_torches_per_branch = 2 + ( branch_length / branch_torch_distance )
local required_torches = required_torches_per_branch * ( branch_count + 1 )
-- Ensure we have enough torches
local torchSlotInfo = turtle.getItemDetail( torch_slot )
if torchSlotInfo then
if torchSlotInfo.count < required_torches then
print( "Insufficient torches, what about the Grues?" )
print( "I only have "..torchSlotInfo.count..", but I would really like "..required_torches)
return -2
end
else
print( "No torches, I'm afraid of the dark." )
return -1
end
-- Dig the main shaft and prepare to carve teh branches
shell.run("tun", main_adit_length, main_adit_width, "right", 1 )
shell.run("left", 2 )
shell.run("forward", 3 )
shell.run("turn", "left" )
function carve_branch()
shell.run( "carve_branches", branch_count, branch_length, branch_torch_distance )
end
carve_branch()
shell.run( "turn", "right", "2" )
shell.run( "forward", main_adit_width - 1 )
carve_branch()