View difference between Paste ID: 5PrMrtwB and qVX1jm91
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)
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
    
28
	if line%8 == 0 then
29
    	if i%8 == 0 then
30
     	 turtle.select(16)
31
    	  while not turtle.forward() do turtle.dig() end
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
44+
	  if not turtle.detectDown() then
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
  end
103-
	turtle.digDown()
103+
104-
    sleep(0.2)
104+
105
function emptyInv()
106
	turtle.select(15)
107
   	while not turtle.placeDown() do turtle.digDown() end
108
   	for i=1,14 do
109
      	turtle.select(i)
110
      	turtle.dropDown()
111
   	end
112
	turtle.select(1)
113
end
114
115
for x=1,args[1] do
116
  turtle.turnLeft()
117-
	turtle.digDown()
117+
118-
   	sleep(0.2)
118+
119
  turtle.turnRight()
120
 if line%8 == 0 then
121
      turtle.select(16)
122
      turtle.placeDown()
123
      turtle.select(1)
124
  end
125
  while not turtle.forward() do turtle.dig() end
126
    while turtle.detectUp() do
127
      turtle.digUp()
128
      sleep(0.2)
129
    end
130
    while turtle.detectDown() do
131
	  turtle.select(15)
132
	  if not turtle.compareDown() then
133
      	turtle.digDown()
134
	  end
135
	  turtle.select(1)
136
    end
137
  line = line + 1
138
print("Mined " .. x .. ", " .. args[1]-x .. " left to go.")
139
end
140
emptyInv()