SHOW:
|
|
- or go back to the newest paste.
1 | --[[ | |
2 | 2013 (c) psychedelixx | |
3 | - | Minecraft Turtle: Stairs |
3 | + | Minecraft Turtle: Room |
4 | - | 2013-05-21 |
4 | + | 2013-05-22 |
5 | ||
6 | - | Digs a simple stair and places missing ground blocks and torches (every 4th horizontal block). |
6 | + | Digs a room with specified dimensions. |
7 | ||
8 | Usage: | |
9 | - | - use turtle and type "label set <name>" |
9 | + | - use turtle and type "label set <name>" |
10 | - | (to give your turtle an unique name so it remembers its programs) |
10 | + | (to give your turtle an unique name so it remembers its programs) |
11 | - | - type "pastebin get R9NXSxDx stairs" |
11 | + | - type "pastebin get tPQVZfmw room" |
12 | - | - place solid blocks in slot 16 (lower right corner) |
12 | + | - type "room <width> [<length>] [<height>]" |
13 | - | - place torches in slot 15 (left of slot 16) |
13 | + | - default length = width |
14 | - | - type "stairs <height> [<limit>]" |
14 | + | - default height = 2 |
15 | - | • where <height> represents the height of the hallway (3-5 seems good) |
15 | + | - place solid blocks in slot 16 to fill the ground |
16 | - | • and <limit> (optional) represents the Y coordinates digged down |
16 | + | |
17 | - | (if you're at y64 and type in 10, it will dig until it's at y54) |
17 | + | |
18 | function move() | |
19 | if turtle.getFuelLevel() < 2 then | |
20 | turtle.refuel() | |
21 | end | |
22 | - | print( "Usage: stairs <height> [<limit>]" ) |
22 | + | if fillGround and not turtle.detectDown() then |
23 | turtle.select(16) | |
24 | turtle.placeDown() | |
25 | - | height = tonumber(args[1]) |
25 | + | end |
26 | - | limit = 256 |
26 | + | |
27 | - | if #args == 2 then |
27 | + | while not turtle.forward() do |
28 | - | limit = tonumber(args[2]) |
28 | + | turtle.dig() |
29 | end | |
30 | repeat | |
31 | - | if height < 2 then |
31 | + | turtle.digUp() |
32 | - | print( "The height must be >= 2." ) |
32 | + | until not turtle.detectUp() |
33 | end | |
34 | ||
35 | local args = { ... } | |
36 | if #args < 1 then | |
37 | print("") | |
38 | - | while limit > 0 do |
38 | + | print("Usage: room <width> [<length>] [<height>]") |
39 | print("# default length = width") | |
40 | - | if turtle.getFuelLevel() < height*2 then |
40 | + | print("# default height = 2") |
41 | - | turtle.refuel() |
41 | + | print("# place solid blocks in slot 16 to fill the ground") |
42 | - | end |
42 | + | print("") |
43 | - | if turtle.getFuelLevel() < height*2 then |
43 | + | |
44 | - | print("Fuel is almost empty!") |
44 | + | error() |
45 | - | end |
45 | + | |
46 | ||
47 | - | print("") |
47 | + | width = tonumber(args[1]) |
48 | - | print("Remaining: " .. limit) |
48 | + | length = width |
49 | - | print("Next torch in: " .. limit%4 .. "m") |
49 | + | height = 2 |
50 | fillGround = true | |
51 | - | for var = 0, height-3 do |
51 | + | |
52 | if #args >= 2 then | |
53 | - | if var < height-3 then |
53 | + | length = tonumber(args[2]) |
54 | end | |
55 | if #args == 3 then | |
56 | - | if var == 0 and limit%4 == 0 then |
56 | + | height = tonumber(args[3]) |
57 | - | turtle.turnRight() |
57 | + | |
58 | - | turtle.dig() |
58 | + | |
59 | - | turtle.select(15) |
59 | + | if height*width*length < 1 then |
60 | - | turtle.place() |
60 | + | print( "A room must be at least 1m^3." ) |
61 | - | turtle.turnLeft() |
61 | + | |
62 | end | |
63 | ||
64 | - | for var = 0, height-4 do turtle.down() end |
64 | + | if turtle.getFuelLevel() == 0 then |
65 | - | turtle.digDown() |
65 | + | turtle.refuel() |
66 | end | |
67 | - | if not turtle.detectDown() then |
67 | + | |
68 | - | turtle.select(16) |
68 | + | if turtle.getFuelLevel() == 0 then |
69 | - | turtle.placeDown() |
69 | + | print("I need fuel!") |
70 | else | |
71 | print("======== 2013 (c) psychedelixx ========") | |
72 | - | while not turtle.forward() do |
72 | + | |
73 | - | turtle.dig() |
73 | + | print("Digging " .. width .. "*" .. length .. "*" .. height .. " (w*l*h)") |
74 | - | end |
74 | + | move() |
75 | ||
76 | - | turtle.forward() |
76 | + | nextTurnRight = true |
77 | - | limit = limit-1 |
77 | + | h = 0 |
78 | - | end |
78 | + | |
79 | repeat | |
80 | w = 1 | |
81 | while w <= width do | |
82 | print("") | |
83 | if turtle.getFuelLevel() ~= "unlimited" then | |
84 | print("Fuel: " .. turtle.getFuelLevel()) | |
85 | end | |
86 | for l = 1, length-1 do | |
87 | move() | |
88 | end | |
89 | if w < width then | |
90 | if nextTurnRight then | |
91 | turtle.turnRight() | |
92 | move() | |
93 | turtle.turnRight() | |
94 | nextTurnRight = false | |
95 | else | |
96 | turtle.turnLeft() | |
97 | move() | |
98 | turtle.turnLeft() | |
99 | nextTurnRight = true | |
100 | end | |
101 | end | |
102 | w = w+1 | |
103 | end | |
104 | if h < height-1 then | |
105 | h = h+2 | |
106 | else | |
107 | if h == height-1 then | |
108 | h = h+1 | |
109 | end | |
110 | end | |
111 | ||
112 | if h < height then | |
113 | turtle.turnRight() | |
114 | turtle.turnRight() | |
115 | turtle.up() | |
116 | turtle.digUp() | |
117 | if h < height-1 then | |
118 | turtle.up() | |
119 | turtle.digUp() | |
120 | end | |
121 | end | |
122 | fillGround = false | |
123 | until h >= height | |
124 | ||
125 | while h > 2 do | |
126 | turtle.down() | |
127 | h = h-1 | |
128 | end | |
129 | ||
130 | ||
131 | end |