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 | ||
48 | local direction = true | |
49 | for i = 1, z do | |
50 | roomSize = x * y * (z-i) | |
51 | while turtle.getFuelLevel() < roomSize do | |
52 | turtle.select(1) | |
53 | turtle.refuel(1) | |
54 | end | |
55 | ||
56 | for j = 1, y do | |
57 | for k = 1, x do | |
58 | turtle.dig() | |
59 | turtle.forward() | |
60 | if direction then | |
61 | posX = posX + 1 | |
62 | else | |
63 | posX = posX - 1 | |
64 | end | |
65 | 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 | |
66 | turtle.turnLeft() | |
67 | turtle.select(2) | |
68 | turtle.place() | |
69 | turtle.turnRight() | |
70 | end | |
71 | end | |
72 | if j < y then | |
73 | if direction then | |
74 | turtle.turnRight() | |
75 | turtle.dig() | |
76 | turtle.forward() | |
77 | posY = posY + 1 | |
78 | turtle.turnRight() | |
79 | direction = false | |
80 | else | |
81 | turtle.turnLeft() | |
82 | turtle.dig() | |
83 | turtle.forward() | |
84 | posY = posY + 1 | |
85 | turtle.turnLeft() | |
86 | direction = true | |
87 | end | |
88 | end | |
89 | if(turtle.getItemCount(16) > 0) then | |
90 | goUnload(i, j, k, direction) | |
91 | end | |
92 | if i < z then | |
93 | turtle.digUp() | |
94 | turtle.up() | |
95 | posZ = posZ + 1 | |
96 | turtle.turnRight() | |
97 | turtle.turnRight() | |
98 | end | |
99 | end | |
100 | ||
101 | ||
102 | ||
103 | ||
104 | if z % 2 == 0 then | |
105 | for i = 1, z do | |
106 | turtle.down() | |
107 | posZ = posZ - 1 | |
108 | end | |
109 | turtle.turnRight() | |
110 | for inventory = inventory_start, 16 do | |
111 | turtle.select(inventory) | |
112 | turtle.drop() | |
113 | end | |
114 | turtle.turnRight() | |
115 | else | |
116 | if y % 2 == 0 then | |
117 | turtle.turnRight() | |
118 | for i = 1, y-1 do | |
119 | turtle.forward() | |
120 | posY = posY - 1 | |
121 | end | |
122 | for i = 1, z do | |
123 | turtle.down() | |
124 | posZ = posZ - 1 | |
125 | end | |
126 | for inventory = inventory_start, 16 do | |
127 | turtle.select(inventory) | |
128 | turtle.drop() | |
129 | end | |
130 | turtle.turnRight() | |
131 | else | |
132 | turtle.turnLeft() | |
133 | for i = 1, y-1 do | |
134 | turtle.forward() | |
135 | posY = posY - 1 | |
136 | end | |
137 | turtle.turnLeft() | |
138 | for i = 1, x-1 do | |
139 | turtle.forward() | |
140 | posX = posX - 1 | |
141 | end | |
142 | for i = 1, z do | |
143 | turtle.down() | |
144 | posZ = posZ - 1 | |
145 | end | |
146 | turtle.turnRight() | |
147 | for inventory = inventory_start, 16 do | |
148 | turtle.select(inventory) | |
149 | turtle.drop() | |
150 | end | |
151 | turtle.turnRight() | |
152 | end | |
153 | end | |
154 | ||
155 | ||
156 | function goUnload(i, j, k, direction) | |
157 | if direction then | |
158 | turtle.turnLeft() | |
159 | else | |
160 | turtle.turnRight() | |
161 | for m = 1, j-1 do | |
162 | turtle.forward() | |
163 | end | |
164 | turtle.turnLeft() | |
165 | for m = 1, k-1 do | |
166 | turtle.forward() | |
167 | end | |
168 | for m = 1, i-1 do | |
169 | turtle.down() | |
170 | end | |
171 | turtle.turnRight() | |
172 | for inventory = inventory_start, 16 do | |
173 | turtle.select(inventory) | |
174 | turtle.drop() | |
175 | end | |
176 | turtle.turnRight() | |
177 | for m = 1, i-1 do | |
178 | turtle.up() | |
179 | end | |
180 | for m = 1, k-1 do | |
181 | turtle.forward() | |
182 | end | |
183 | turtle.turnRight() | |
184 | for m = 1, j-1 do | |
185 | turtle.forward() | |
186 | end | |
187 | if direction then | |
188 | turtle.turnLeft() | |
189 | else | |
190 | turtle.turnRight() | |
191 | end |