View difference between Paste ID: ciE59T34 and BqYXcRdn
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
	print("depth = " .. i);
31
	--Dig infront of you.
32
        while turtle.detect() do
33
            turtle.dig()
34
        end
35
	--dig infront of you if you can't move forward.
36
        while not turtle.forward() do
37
            turtle.dig()
38
        end
39
    end
40
end
41
42
function digPlane(x, y) 
43
	for i=0, y, 1 do
44
		print("width = " .. i);
45
		--Mine 1 row
46
		mineRow(x/2);
47
		turtle.turnLeft();
48
		--Else turn around and get ready for the next one.
49
		mineRow(0);
50
		turtle.turnLeft();
51
		--Mine 1 row
52
		mineRow(x/2);
53
		turtle.turnRight();
54
		--Exit if we've finished this area.
55
		i = i + 1
56
		print("width = " .. i);
57-
		if i+1 >= y then
57+
		if tonumber(i+1) >= tonumber(y) then
58
			break
59
		end
60
		--Mine column a little
61
		mineRow(0);
62
		turtle.turnRight();
63
	end
64
	--Turn around and get ready for the next plane.
65
	turtle.turnRight();
66
	mineRow(1);
67
end
68
69
function digCube(x, y, z)
70
	print(x)
71
	print(y)
72
	print(z)
73
	for i=0, z, 1 do
74
		print("height = " .. i);
75
		digPlane(x, y);
76
		--Dig above you
77
	        while turtle.detectUp() do
78
	            turtle.digUp()
79
	        end
80
		--Move up
81
	        while not turtle.up() do
82
	            turtle.digUp()
83
	        end
84
	end
85
end
86
87
digCube(length, width, height);