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 | while(turtle.forward() == false) do | |
65 | turtle.dig() | |
66 | end | |
67 | end | |
68 | turtle.turnLeft() | |
69 | for m = 1, posX-1 do | |
70 | while(turtle.forward() == false) do | |
71 | turtle.dig() | |
72 | end | |
73 | end | |
74 | for m = 1, posZ-2 do | |
75 | while(turtle.down() == false) do | |
76 | turtle.digDown() | |
77 | end | |
78 | end | |
79 | turtle.turnRight() | |
80 | for inventory = inventory_start, 16 do | |
81 | turtle.select(inventory) | |
82 | turtle.drop() | |
83 | end | |
84 | turtle.turnRight() | |
85 | for m = 1, posZ-2 do | |
86 | turtle.up() | |
87 | end | |
88 | for m = 1, posX-1 do | |
89 | turtle.forward() | |
90 | end | |
91 | turtle.turnRight() | |
92 | for m = 1, posY-1 do | |
93 | turtle.forward() | |
94 | end | |
95 | if(posZ % 2 == 0) then | |
96 | if direction then | |
97 | turtle.turnRight() | |
98 | else | |
99 | turtle.turnLeft() | |
100 | end | |
101 | else | |
102 | if direction then | |
103 | turtle.turnLeft() | |
104 | else | |
105 | turtle.turnRight() | |
106 | end | |
107 | end | |
108 | turtle.up() | |
109 | turtle.select(inventory_start) | |
110 | end | |
111 | ||
112 | ||
113 | ||
114 | local direction = true | |
115 | for i = 1, z do | |
116 | roomSize = x * y * (z-i) | |
117 | while turtle.getFuelLevel() < roomSize do | |
118 | turtle.select(1) | |
119 | turtle.refuel(1) | |
120 | end | |
121 | ||
122 | for j = 1, y do | |
123 | for k = 1, x do | |
124 | - | while (turtle.detect()) do |
124 | + | turtle.dig() |
125 | while(turtle.forward() == false) do | |
126 | turtle.dig() | |
127 | end | |
128 | if (i % 2 ~= 0) then | |
129 | if direction then | |
130 | posX = posX + 1 | |
131 | else | |
132 | posX = posX - 1 | |
133 | end | |
134 | else | |
135 | if direction then | |
136 | posX = posX - 1 | |
137 | else | |
138 | posX = posX + 1 | |
139 | end | |
140 | end | |
141 | 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 | |
142 | turtle.turnLeft() | |
143 | turtle.select(2) | |
144 | turtle.place() | |
145 | turtle.turnRight() | |
146 | end | |
147 | end | |
148 | if j < y then | |
149 | if direction then | |
150 | turtle.turnRight() | |
151 | turtle.dig() | |
152 | while(turtle.forward() == false) do | |
153 | - | while (turtle.detect()) do |
153 | + | |
154 | end | |
155 | - | end |
155 | + | |
156 | direction = false | |
157 | else | |
158 | turtle.turnLeft() | |
159 | turtle.dig() | |
160 | while(turtle.forward() == false) do | |
161 | turtle.dig() | |
162 | end | |
163 | - | while (turtle.detect()) do |
163 | + | |
164 | direction = true | |
165 | - | end |
165 | + | |
166 | if(i % 2 ~= 0) then | |
167 | posY = posY + 1 | |
168 | else | |
169 | posY = posY - 1 | |
170 | end | |
171 | end | |
172 | if(turtle.getItemCount(16) > 0) then | |
173 | goUnload(direction, inventory_start) | |
174 | end | |
175 | end | |
176 | if i < z then | |
177 | turtle.digUp() | |
178 | turtle.up() | |
179 | posZ = posZ + 1 | |
180 | turtle.turnRight() | |
181 | turtle.turnRight() | |
182 | end | |
183 | - | while (turtle.detectUp()) do |
183 | + | |
184 | - | turtle.digUp() |
184 | + | |
185 | ||
186 | ||
187 | ||
188 | if z % 2 == 0 then | |
189 | for i = 1, z do | |
190 | while(turtle.down() == false) do | |
191 | turtle.digDown() | |
192 | end | |
193 | posZ = posZ - 1 | |
194 | end | |
195 | turtle.turnRight() | |
196 | for inventory = inventory_start, 16 do | |
197 | turtle.select(inventory) | |
198 | turtle.drop() | |
199 | end | |
200 | turtle.turnRight() | |
201 | else | |
202 | if y % 2 == 0 then | |
203 | turtle.turnRight() | |
204 | for i = 1, y-1 do | |
205 | while(turtle.forward() == false) do | |
206 | turtle.dig() | |
207 | end | |
208 | posY = posY - 1 | |
209 | end | |
210 | for i = 1, z do | |
211 | while(turtle.down() == false) do | |
212 | turtle.digDown() | |
213 | end | |
214 | posZ = posZ - 1 | |
215 | end | |
216 | for inventory = inventory_start, 16 do | |
217 | turtle.select(inventory) | |
218 | turtle.drop() | |
219 | end | |
220 | turtle.turnRight() | |
221 | else | |
222 | turtle.turnLeft() | |
223 | for i = 1, y-1 do | |
224 | while(turtle.forward() == false) do | |
225 | turtle.dig() | |
226 | end | |
227 | posY = posY - 1 | |
228 | end | |
229 | turtle.turnLeft() | |
230 | for i = 1, x-1 do | |
231 | while(turtle.forward() == false) do | |
232 | turtle.dig() | |
233 | end | |
234 | posX = posX - 1 | |
235 | end | |
236 | for i = 1, z do | |
237 | while(turtle.down() == false) do | |
238 | turtle.digDown() | |
239 | end | |
240 | posZ = posZ - 1 | |
241 | end | |
242 | turtle.turnRight() | |
243 | for inventory = inventory_start, 16 do | |
244 | turtle.select(inventory) | |
245 | turtle.drop() | |
246 | end | |
247 | turtle.turnRight() | |
248 | end | |
249 | end |