View difference between Paste ID: 5KnL2JSN and 99MtfLBp
SHOW: | | - or go back to the newest paste.
1
acceptableItems = {'minecraft:diamond','minecraft:coal','minecraft:iron_ore','minecraft:emerald','minecraft:gold_ore','draconicevolution:draconium_dust'}
2
acceptableItemsLength = 6
3
-- 1 breaks up, -1 breaks down
4
function destroy (direction)
5
	if direction == 1 then
6
		turtle.digUp()
7
		turtle.up()
8
	elseif direction == -1 then
9
		turtle.digDown()
10
		turtle.down()
11
	else
12
		error('invalid direction')
13
	end
14
    turtle.dig()
15
    turtle.turnLeft()
16
    turtle.turnLeft()
17
    turtle.dig()
18
    turtle.turnLeft()
19
    turtle.turnLeft()
20
end
21
22
-- if coal slot (1) has more than one coal, use
23
function refuel ()
24
	if turtle.getItemCount(1) > 1 then
25
		temp = turtle.getSelectedSlot()
26
		turtle.select(1)
27
		turtle.refuel(turtle.getItemCount()-1)
28
		turtle.select(temp)
29
	end
30
end
31
32
-- remove all items not in list
33
function purge ()
34
	for i=2,16 do
35
		keep = false
36
		for j=1,acceptableItemsLength do
37-
				break
37+
38
				keep = true
39-
			if j == acceptableItemsLength then
39+
40-
				turtle.select(i)
40+
41-
				turtle.drop()
41+
		if not keep then
42
			turtle.select(i)
43
			turtle.drop(i)
44
		end
45
	end
46
end
47
48
-- returns true if every slot is completely full
49
function turtleInvFull ()
50
	fullCount = 0; -- # of slots full
51
	for i=2,16 do
52
		if turtle.getItemSpace(i) == 0 then
53
			fullCount = fullCount + 1;
54
		end
55
	end
56
	return fullCount == 15;
57
end
58
59
60
while (turtle.getFuelLevel() > 0) and not turtleInvFull() do
61
	-- mining down
62
	repeat
63
		success, data = turtle.inspectDown()
64
		destroy(-1)
65
		refuel()
66
		purge()
67
	until data.name == 'minecraft:bedrock'
68
69
	-- moves to new spot to mine up
70
	for i=1,3 do
71
		turtle.dig()
72
		turtle.forward()
73
	end
74
	
75
	-- end if turtle inv completely full
76
	if turtleInvFull() then
77
		break
78
	end
79
		
80
	-- mining up
81
	for i=2,70 do
82
		destroy(1)
83
		refuel()
84
		purge()
85
	end
86
87
	-- moves to new spot to mine down
88
	for i=1,3 do
89
		turtle.forward()
90
		turtle.dig()
91
	end
92
end