View difference between Paste ID: 7fStiTUb and EPfm7fJ2
SHOW: | | - or go back to the newest paste.
1
local tArgs = {...}
2
local length = tArgs[1]
3
local numTunnels = tArgs[2]
4
local inv = true
5
local checkTorch = 0
6
local height = 0
7
8
function tunnel()
9
  term.clear()
10
  term.setCursorPos(1,1)
11
  print("Mining...")
12
  for i=1,length do
13
    fuel()
14
    turtle.dig()
15
    while turtle.forward() == false do
16
      turtle.dig()
17
    end 
18
    turtle.digUp()
19
    torch()
20
  end
21
end
22
23
function turnAround()
24
  term.clear()
25
  term.setCursorPos(1,1)
26
  print("Turning around...")
27
  for k = 1,6 do
28
    fuel()
29
    turtle.dig()
30
    while turtle.forward() == false do
31
      turtle.dig()
32
    end
33
    turtle.digUp()
34
    torch()
35
  end
36
  
37
  checkInv()
38
  
39
  while turtle.back() == false do
40
    turtle.turnRight()
41
    turtle.turnRight()
42
    turtle.dig()
43
    for i = 1,3 do
44
      turtle.forward()
45
      turtle.dig()
46
    end
47
    turtle.turnRight()
48
    turtle.turnRight()
49
    for i = 1,3 do
50
      turtle.back()  
51
    end
52
  end
53
  turtle.back()
54
  turtle.back()
55
end
56
57
function checkInv()
58
  term.clear()
59
  term.setCursorPos(1,1)
60
  print("Trashing...")
61
  for y = 2,16 do
62
    turtle.select(y)
63
    if turtle.compareTo(1) then
64
      turtle.drop()
65
    end
66
  end
67
end
68
69
function torch()
70
  if turtle.getItemCount(16) < 5 then
71
    term.clear()
72
    term.setCursorPos(1,1)
73
    print("Waiting for torches...place in bottom right.")
74
    while turtle.getItemCount(16) < 5 do
75
      sleep(2)
76
    end
77
  end
78
  term.clear()
79
  term.setCursorPos(1,1)
80
  print("Mining...")
81
  if checkTorch == 8 then
82
    fuel()
83
    turtle.select(16)
84
    turtle.up()
85
    turtle.digUp()
86
    if turtle.placeUp() or turtle.getItemCount(16) == 0 then
87
        for i = 0,height do
88
          fuel()
89
          turtle.down()
90
        end
91
        turtle.select(1)
92
        checkTorch = 0
93
        height = 0
94
    else
95
        height = height + 1
96
        torch()
97
    end
98
  else
99
    checkTorch = checkTorch + 1
100
  end
101
end
102
103
function fuel()
104
  if turtle.getFuelLevel() < 50 then
105
    print ("Wating for fuel...place in bottom left.")     
106
    while turtle.getFuelLevel() < 50 do
107
      turtle.select(13)
108
      turtle.refuel()
109
      sleep(2)
110
    end
111
  end
112
  term.clear()
113
  term.setCursorPos(1,1)
114
  print("Mining...")
115
  turtle.select(1)
116
end
117
118
function begin()
119
  turtle.select(1)
120
  if turtle.getItemCount(1) == 0 then
121
    print("Please place an item to trash in the top left.")
122
    while turtle.getItemCount(1) == 0 do
123
      sleep(1)
124
    end
125
    term.clear()
126
    term.setCursorPos(1,1)
127
    begin()
128
  else
129
    print("The item in the top left will be trashed...confirm?")
130
    os.pullEvent("key")
131
  end
132
  term.clear()
133
  term.setCursorPos(1,1)
134
end
135
          
136
begin()
137
for j = 1,numTunnels do
138
  tunnel()
139
  turtle.turnLeft()
140
  turnAround()
141
  turtle.turnLeft()
142
  tunnel()
143
  turtle.turnRight()
144
  turnAround()
145
  turtle.turnRight()
146
end
147
term.clear()
148
term.setCursorPos(1,1)
149
print("Done!")