View difference between Paste ID: AcEcLwDe and 5PrMrtwB
SHOW: | | - or go back to the newest paste.
1
local args = {...}
2
3
local stripLength = 33
4
local count = 0
5
local line = 0
6
7
if not #args == 1 then
8
  print("Usage: smine <mines>")
9
  return
10
end
11
12
function strip()
13
  count = 0
14
  for i=1,stripLength do
15
	count = count + 1
16-
    checkFuel(count)
16+
17
    while not turtle.forward() do turtle.dig() end
18
    while turtle.detectUp() do
19
      turtle.digUp()
20
      sleep(0.2)
21
    end
22
    while turtle.detectDown() do
23
      turtle.digDown()
24
      sleep(0.2)
25
    end
26
    
27
	if line%8 == 0 then
28
    	if i%8 == 0 then
29
     	 turtle.select(16)
30
    	  while not turtle.forward() do turtle.dig() end
31
    	  while turtle.detectDown() do
32
   	     turtle.digDown()
33
  	      sleep(0.2)
34
    	  end
35
      if not turtle.back() then
36
        turtle.turnLeft()
37
		turtle.turnLeft()
38
        while not turtle.forward do turtle.dig() end
39
        turtle.turnLeft()
40
		turtle.turnLeft()
41
      end
42
	  turtle.down()
43
	  if not turtle.detectDown() then
44
		 turtle.select(1)
45
		 turtle.placeDown()
46
         turtle.select(16)
47
      end
48
	  turtle.up()
49
      turtle.placeDown()
50
      turtle.select(1)
51
    end
52
end
53
  end
54
  
55
  turtle.turnLeft()
56
  turtle.turnLeft()
57
  
58
  for i=1,stripLength do
59
    while not turtle.forward() do turtle.dig() end
60
  end
61
end
62
63
function checkFuel(count)
64
  if turtle.getFuelLevel() <= count then
65
    print("Error: Low fuel")
66
    for i=1,14 do
67
      turtle.select(i)
68
      turtle.refuel()
69
    end
70
	turtle.select(1)
71
	if turtle.getFuelLevel() <= count then
72
		turtle.turnLeft()
73
   		turtle.turnLeft()
74
		print("returning")
75
        print(count)
76
		for i=0,count do
77
			turtle.forward()
78
		end
79
		emptyInv()
80
		turtle.turnRight()
81
	end
82
  end
83
end
84
85
function checkInv()
86
  isFull = true
87
  
88
  for i=1,14 do
89
    if turtle.getItemCount(i) == 0 then
90
      isFull = false
91
    end
92
  end
93
  
94
  if isFull == true then
95
    turtle.select(15)
96
    while not turtle.placeDown() do turtle.digDown() end
97
    for i=1,14 do
98
      turtle.select(i)
99
      turtle.dropDown()
100
    end
101
  end
102
end
103
104
function emptyInv()
105
	turtle.select(15)
106
   	while not turtle.placeDown() do turtle.digDown() end
107
   	for i=1,14 do
108
      	turtle.select(i)
109
      	turtle.dropDown()
110
   	end
111
	turtle.select(1)
112
end
113
114
for x=1,args[1] do
115
  turtle.turnLeft()
116
  strip()
117
  strip()
118
  turtle.turnRight()
119
 if line%8 == 0 then
120
      turtle.select(16)
121
      turtle.placeDown()
122
      turtle.select(1)
123
  end
124
  while not turtle.forward() do turtle.dig() end
125
    while turtle.detectUp() do
126
      turtle.digUp()
127
      sleep(0.2)
128
    end
129
    while turtle.detectDown() do
130
	  turtle.select(15)
131
	  if not turtle.compareDown() then
132
      	turtle.digDown()
133
	  end
134
	  turtle.select(1)
135
    end
136
  line = line + 1
137
print("Mined " .. x .. ", " .. args[1]-x .. " left to go.")
138
end
139
emptyInv()