View difference between Paste ID: RdLSrmHL and u5quiA33
SHOW: | | - or go back to the newest paste.
1
local t = turtle
2
3
local function dropCheck()
4
	while true do
5
		os.sleep(1)
6
		if t.detect == true then
7
		t.dig()				--clears falling blocks until there are no more blocks in the space ahead
8
		else
9
		break
10
		end
11
	end
12
end
13
14
local function reSupply()
15
	t.select(15)
16
	t.turnLeft()
17
	t.dig()
18
	t.place()
19
20-
local function clearInventory()
20+
	for i = 9, 14, 1 do			--places red ender chest and gets inventory to place for slots 9-14
21
		t.select(i)
22
		t.suck()
23
	end
24
25
	t.select(15)
26
	t.dig()
27-
        for i = 1, 15, 1 do       -- selects all slots and places in chest
27+
28
end
29
30
31
local function clearInventory()		--places white ender chest and selects inventory slots 1-8 and places them in it
32
 
33
        t.select(16)   
34
        t.turnRight()  
35
        t.dig()
36
        t.place()
37
       
38
        for i = 1, 8, 1 do       
39
                t.select(i)
40
                t.drop()
41
	end
42
 
43
        t.select(16)
44
        t.dig()
45-
		break end
45+
46
end
47-
		if t.getItemCount(14) == 0 then
47+
48
local function matCheck()
49
50
	for i = 9, 14, 1 do
51
		
52
		itemCount = t.getItemCount(i)
53
		t.select(i)
54
		if itemCount > 0 then
55
56
		break end				--if slot 14 has less than 64 supply, the resupply function is run
57
58
		if t.getItemCount(14) < 64 then
59-
	itemCount = t.getItemCount(8)     
59+
60
		end
61
	end
62
end
63
64-
	matCheck()	
64+
65
66
	blockAbove = false	
67
68
	repeat
69
70
	itemCount = t.getItemCount(8)     --checks last open incoming slot and if it has inventory, will clearinventory
71
        if itemCount > 0 then
72
        	clearInventory()
73
	end
74
75
	matCheck()			  --Digs up until a block is detected above the turtle
76
	t.dig()
77
	dropCheck()
78
	t.place()
79
	t.up()
80
	
81
	if t.detectUp() then
82
		blockAbove = true
83
	end
84
	
85
	until blockAbove == true
86
end
87
	
88
local function keepGoing()
89
	
90
	t.turnRight()
91
	flag = true
92
	
93
	if t.detect() then			--determines if there is a block to the right of the turtle and stops program
94
	flag = false				--if there is
95
	end
96
	
97
	t.turnLeft()
98-
	if itemCount > 0 then
98+
99
end
100
	
101
local function topDown()
102
	
103
	itemCount = t.getItemCount(16)
104
        if itemCount > 0 then
105
        	clearInventory()
106
	end						--positions the turtle at the top of a column to start digging down
107
108
	matCheck()
109
	t.dig()
110
	t.place()
111
	t.turnRight()
112
	t.forward()
113
	t.turnLeft()
114
end
115
116
local function goingDown()
117
	
118
	blockBelow = false
119
120
	repeat
121
	
122
	itemCount = t.getItemCount(8)
123
	if itemCount > 0 then		--checks inventory and digs down until a block is undearneath
124
       		clearInventory()
125
	end
126
127
	matCheck()
128
	t.dig()
129
	t.place()
130
	t.down()
131
132-
	flag = false
132+
133
		blockBelow = true
134-
	if t.detect() then
134+
135
136
	until blockBelow == true
137
end
138
	
139
local function bottomUp()
140
141
	itemCount = t.getItemCount(8)
142-
local function wallDown()
142+
143-
	for i = 0, 63, 1 do
143+
144-
		t.dig()
144+
	end				--positions the turtle at the bottom of next column to start digging up.
145-
		t.forward()
145+
146
	matCheck()
147-
		for j = 0, 64, 1 
147+
148-
			t.digDown()
148+
149-
			t.down()
149+
150-
			
150+
151
	t.turnLeft()
152-
		clearInventory()
152+
153
154-
		t.dig()
154+
--_________________________________END OF FUNCTIONS________________________________________
155-
		t.forward()
155+
while true do
156-
		for j = 0, 64, 1 do
156+
	goingUp()
157-
			t.digUp()
157+
		if keepGoing() == false
158-
			t.up()
158+
			break
159
		end
160-
		clearInventory()
160+
	topDown()
161
	goingDown()
162
		if keepGoing() == false
163
			break
164-
wallDown()	
164+
165
	bottomUp()
166
end