SHOW:
|
|
- or go back to the newest paste.
1 | local tArgs = { ... } | |
2 | -- check number of arguments | |
3 | if #tArgs < 3 or #tArgs > 4 then | |
4 | - | error("Usage: room <depth> <height> <width>") |
4 | + | error("Usage: #ProgramName <depth> <height> <width>") |
5 | end | |
6 | ||
7 | depth = tonumber(tArgs[1]) | |
8 | height = tonumber(tArgs[2]) | |
9 | width = tonumber(tArgs[3]) | |
10 | ||
11 | print("Digging Room D"..tArgs[1].."xH"..tArgs[2].."xW"..tArgs[3]); | |
12 | -- move forward to create room | |
13 | turtle.dig() | |
14 | turtle.forward() | |
15 | -- adjust depth for the step | |
16 | depth = depth - 1 | |
17 | -- create room | |
18 | for widthTemp = 1, width do | |
19 | for heightTemp = 1, height do | |
20 | for depthTemp = 1, depth do | |
21 | -- dig straight forward | |
22 | while turtle.detect() do | |
23 | turtle.dig() | |
24 | os.sleep(1) -- needed to work with gravel | |
25 | end | |
26 | turtle.forward() | |
27 | end | |
28 | -- line complete, move to next line | |
29 | if heightTemp<height then | |
30 | while turtle.detectUp() do | |
31 | turtle.digUp() | |
32 | end | |
33 | turtle.up() | |
34 | turtle.turnLeft() | |
35 | turtle.turnLeft() | |
36 | end | |
37 | end | |
38 | -- slice complete, return to start | |
39 | -- move back on odd heights, otherwise we are already back | |
40 | if height % 2 == 1 then | |
41 | turtle.turnLeft() | |
42 | turtle.turnLeft() | |
43 | for depthTemp=1, depth do | |
44 | turtle.forward() | |
45 | os.sleep(1) | |
46 | end | |
47 | end | |
48 | -- move down | |
49 | for heightTemp=0, height-1 do | |
50 | turtle.down() | |
51 | end | |
52 | -- next slice | |
53 | if widthTemp<width then | |
54 | turtle.turnLeft() | |
55 | while turtle.detect() do | |
56 | turtle.dig() | |
57 | end | |
58 | turtle.forward() | |
59 | turtle.turnLeft() | |
60 | end | |
61 | end |