View difference between Paste ID: 4CxUnAzg and chtjGwQY
SHOW: | | - or go back to the newest paste.
1
args = {...}
2
width = args[1];
3
length = args[2];
4
height = args[3];
5
6
if width==nil then
7
	error("Width not specified");
8
end
9
if length==nil then
10
	error("Length not specified");
11
end
12
if height==nil then
13
	error("Height not specified");
14
end
15
16
turtle.turnRight();
17
for i=0, width/2-1, 1 do
18
	--Assuming that we were put in the centre of one side of the bottom of the cube
19
	-- move to the side of the cube to start.
20
	turtle.dig();
21
        while not turtle.forward() do
22
            turtle.dig()
23
        end
24
end
25
turtle.turnLeft();
26
27
28
function mineRow(num)
29
    for i=0, num, 1 do
30
	--Dig infront of you.
31
        while turtle.detect() do
32
            turtle.dig()
33
        end
34
	--dig infront of you if you can't move forward.
35
        while not turtle.forward() do
36
            turtle.dig()
37
        end
38
    end
39
end
40
41
function digPlane(x, y) 
42
	for i=0, y, 1 do
43
		--Mine 1 row
44
		mineRow(x/2);
45
		turtle.turnLeft();
46
		--Else turn around and get ready for the next one.
47
		mineRow(0);
48
		turtle.turnLeft();
49
		--Mine 1 row
50
		mineRow(x/2);
51
		turtle.turnRight();
52
		--Exit if we've finished this area.
53-
		--if i+1 >= y then
53+
		i = i + 1
54-
		--	break
54+
		if i+1 >= y then
55-
		--end
55+
			break
56
		end
57
		--Mine column a little
58
		mineRow(0);
59
		turtle.turnRight();
60
	end
61
	--Turn around and get ready for the next plane.
62
	turtle.turnRight();
63
	mineRow(1);
64
end
65
66
function digCube(x, y, z)
67
	for i=0, z, 1 do
68
		digPlane(x, y);
69
		--Dig above you
70
	        while turtle.detectUp() do
71
	            turtle.digUp()
72
	        end
73
		--Move up
74
	        while not turtle.up() do
75
	            turtle.digUp()
76
	        end
77
	end
78
end
79
80
digCube(length, width, height);