View difference between Paste ID: XFxcchrS and SWXVpm72
SHOW: | | - or go back to the newest paste.
1
-- Strip mining turtle program.
2
-- Luke *********, Ryszard ********. 13/12/12
3
-- updated by AzrylAero 5/3/2013
4
-- modified for 2 wide by krakaen 14/11/20
5
6
--[[fuel must be placed in slot 14,
7
    mainshaft torches must be placed in slot 15
8
    tunnel torches must be placed in slot 16.]]
9
10
-- Create the function for refueling
11
function checkFuel()
12
  if turtle.getFuelLevel() <= 10 then
13
    turtle.select(14)
14
    turtle.refuel(1)
15
    turtle.select(1)
16
  end --if
17
end --checkFuel()
18
19
-- Create the turnAround function
20
function turnAround()
21
  turtle.turnRight()
22
  turtle.turnRight()
23
end --turnAround()
24
25
-- Go to the next tunnel
26
function digNext(torchCounter)
27
   turtle.turnRight()
28
  turtle.dig()
29
  turtle.forward()
30
  turtle.digUp()
31
  turtle.dig()
32
turtle.forward()
33-
  if torchCounter == 2 then
33+
34
  turtle.dig()
35-
   turnAround()
35+
36-
   turtle.select(15)
36+
37-
   turtle.place()
37+
38-
   turnAround()
38+
39-
   print("Placing mainshaft torch")
39+
40-
  end
40+
41
  
42
43
--Dig Next End
44
45
-- Digs the tunnel for the given length
46
function tunnel(givenLength)
47
  local distance = 0
48
  for index = 1,givenLength do
49
    turtle.dig()
50
    if turtle.forward() then
51
      distance = distance + 1
52
    end --if
53
    turtle.digUp()
54
    turtle.select(1)
55
    turtle.placeDown()
56
57
-- Places a torch every 10 blocks
58
    if distance == 10 then
59
      distance = 0
60
      checkFuel()
61
    end --if
62
  end --for
63-
      turtle.select(16)
63+
64-
      print("Placing tunnel torch...")
64+
65-
      turnAround()
65+
66-
      turtle.place()
66+
67-
      turnAround()
67+
68
   end --for
69
   turtle.down()
70
end --tunnel()
71
72
-- Main script
73
print("Input tunnel length:")
74
local length = read()
75
print("Tunnel quantity")
76
local quantity = read()
77
local torchNext = 0
78
print("starting excavation...")
79
checkFuel()
80
-- Tunnel loop
81
  for index=1,quantity do
82
  if torchNext == 3 then
83
    torchNext = 0
84
  end   
85
  tunnel(length)
86
  checkFuel()
87
  digNext(torchNext)
88
  torchNext = torchNext + 1
89
 end
90
print("The tunnel(s) has been excavated!")