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