SHOW:
|
|
- or go back to the newest paste.
1 | local tArgs = {...} | |
2 | if #tArgs ~= 3 then | |
3 | print("Requires length, width, height") | |
4 | return | |
5 | end | |
6 | ||
7 | local x = tonumber(tArgs[1]) - 1 | |
8 | local y = tonumber(tArgs[2]) | |
9 | local z = tonumber(tArgs[3]) | |
10 | ||
11 | local posX = 1 | |
12 | local posY = 1 | |
13 | local posZ = 1 | |
14 | ||
15 | if x == nil or y == nil or z == nil then | |
16 | print("Invalid dimensions") | |
17 | return | |
18 | end | |
19 | ||
20 | if x < 0 or y < 0 or z < 0 then | |
21 | print("Invalid (negative) dimensions") | |
22 | return | |
23 | end | |
24 | ||
25 | local torch = 0 | |
26 | local inventory_start = 2 | |
27 | print("Use torches? (y/n)") | |
28 | local input = io.read() | |
29 | if(input == "y") then | |
30 | torch = 2 | |
31 | inventory_start = 3 | |
32 | else | |
33 | torch = 0 | |
34 | end | |
35 | ||
36 | local roomSize = x * y * z | |
37 | print("Storing fuel for mining process...") | |
38 | turtle.select(1) | |
39 | while turtle.getFuelLevel() < roomSize do | |
40 | if not turtle.refuel(1) then | |
41 | print("Not enough fuel. Please insert more fuel.") | |
42 | return | |
43 | end | |
44 | end | |
45 | ||
46 | ||
47 | --[[Funcao que vai descarregar quando e atingido o ultimo slot]]-- | |
48 | function goUnload(direction, inventory_start) | |
49 | turtle.down() | |
50 | if(posZ % 2 == 0) then | |
51 | if direction then | |
52 | turtle.turnRight() | |
53 | else | |
54 | turtle.turnLeft() | |
55 | end | |
56 | else | |
57 | if direction then | |
58 | turtle.turnLeft() | |
59 | else | |
60 | turtle.turnRight() | |
61 | end | |
62 | end | |
63 | for m = 1, posY-1 do | |
64 | turtle.forward() | |
65 | end | |
66 | turtle.turnLeft() | |
67 | for m = 1, posX-1 do | |
68 | turtle.forward() | |
69 | end | |
70 | for m = 1, posZ-2 do | |
71 | turtle.down() | |
72 | end | |
73 | turtle.turnRight() | |
74 | for inventory = inventory_start, 16 do | |
75 | turtle.select(inventory) | |
76 | turtle.drop() | |
77 | end | |
78 | turtle.turnRight() | |
79 | for m = 1, posZ-2 do | |
80 | turtle.up() | |
81 | end | |
82 | for m = 1, posX-1 do | |
83 | turtle.forward() | |
84 | end | |
85 | turtle.turnRight() | |
86 | for m = 1, posY-1 do | |
87 | turtle.forward() | |
88 | end | |
89 | if(posZ % 2 == 0) then | |
90 | if direction then | |
91 | turtle.turnRight() | |
92 | else | |
93 | turtle.turnLeft() | |
94 | end | |
95 | else | |
96 | if direction then | |
97 | turtle.turnLeft() | |
98 | else | |
99 | turtle.turnRight() | |
100 | end | |
101 | end | |
102 | turtle.up() | |
103 | turtle.select(inventory_start) | |
104 | end | |
105 | ||
106 | ||
107 | ||
108 | local direction = true | |
109 | for i = 1, z do | |
110 | roomSize = x * y * (z-i) | |
111 | while turtle.getFuelLevel() < roomSize do | |
112 | turtle.select(1) | |
113 | turtle.refuel(1) | |
114 | end | |
115 | ||
116 | for j = 1, y do | |
117 | for k = 1, x do | |
118 | - | turtle.dig() |
118 | + | while (turtle.detect()) do |
119 | turtle.dig() | |
120 | end | |
121 | turtle.forward() | |
122 | if (i % 2 ~= 0) then | |
123 | if direction then | |
124 | posX = posX + 1 | |
125 | else | |
126 | posX = posX - 1 | |
127 | end | |
128 | else | |
129 | if direction then | |
130 | posX = posX - 1 | |
131 | else | |
132 | posX = posX + 1 | |
133 | end | |
134 | end | |
135 | if(torch ~=0 and z > 1 and y > 1 and (j+3) % 6 == 0 and i == 1 and k < x and (k == 1 or k % 6 == 0)) then | |
136 | turtle.turnLeft() | |
137 | turtle.select(2) | |
138 | turtle.place() | |
139 | turtle.turnRight() | |
140 | end | |
141 | end | |
142 | if j < y then | |
143 | if direction then | |
144 | turtle.turnRight() | |
145 | while (turtle.detect()) do | |
146 | turtle.dig() | |
147 | end | |
148 | turtle.forward() | |
149 | turtle.turnRight() | |
150 | direction = false | |
151 | else | |
152 | turtle.turnLeft() | |
153 | while (turtle.detect()) do | |
154 | turtle.dig() | |
155 | end | |
156 | turtle.forward() | |
157 | turtle.turnLeft() | |
158 | direction = true | |
159 | end | |
160 | if(i % 2 ~= 0) then | |
161 | posY = posY + 1 | |
162 | else | |
163 | posY = posY - 1 | |
164 | end | |
165 | - | turtle.digUp() |
165 | + | |
166 | if(turtle.getItemCount(16) > 0) then | |
167 | goUnload(direction, inventory_start) | |
168 | end | |
169 | end | |
170 | if i < z then | |
171 | while (turtle.detectUp()) do | |
172 | turtle.digUp() | |
173 | end | |
174 | turtle.up() | |
175 | posZ = posZ + 1 | |
176 | turtle.turnRight() | |
177 | turtle.turnRight() | |
178 | end | |
179 | end | |
180 | ||
181 | ||
182 | ||
183 | ||
184 | if z % 2 == 0 then | |
185 | for i = 1, z do | |
186 | turtle.down() | |
187 | posZ = posZ - 1 | |
188 | end | |
189 | turtle.turnRight() | |
190 | for inventory = inventory_start, 16 do | |
191 | turtle.select(inventory) | |
192 | turtle.drop() | |
193 | end | |
194 | turtle.turnRight() | |
195 | else | |
196 | if y % 2 == 0 then | |
197 | turtle.turnRight() | |
198 | for i = 1, y-1 do | |
199 | turtle.forward() | |
200 | posY = posY - 1 | |
201 | end | |
202 | for i = 1, z do | |
203 | turtle.down() | |
204 | posZ = posZ - 1 | |
205 | end | |
206 | for inventory = inventory_start, 16 do | |
207 | turtle.select(inventory) | |
208 | turtle.drop() | |
209 | end | |
210 | turtle.turnRight() | |
211 | else | |
212 | turtle.turnLeft() | |
213 | for i = 1, y-1 do | |
214 | turtle.forward() | |
215 | posY = posY - 1 | |
216 | end | |
217 | turtle.turnLeft() | |
218 | for i = 1, x-1 do | |
219 | turtle.forward() | |
220 | posX = posX - 1 | |
221 | end | |
222 | for i = 1, z do | |
223 | turtle.down() | |
224 | posZ = posZ - 1 | |
225 | end | |
226 | turtle.turnRight() | |
227 | for inventory = inventory_start, 16 do | |
228 | turtle.select(inventory) | |
229 | turtle.drop() | |
230 | end | |
231 | turtle.turnRight() | |
232 | end | |
233 | end |