View difference between Paste ID: S3dVSyj0 and aEtJ0KYU
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
  if(posZ % 2 == 0) then
50
	if direction then
51
	  turtle.turnRight()
52
    else
53
	  turtle.turnLeft()
54
    end
55
	turtle.down()
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()
119
      turtle.forward()
120-
	  if direction then
120+
	  if (i % 2 ~= 0) then
121-
	    posX = posX + 1
121+
		if direction then
122
	      posX = posX + 1
123-
		posX = posX - 1
123+
		else
124
		  posX = posX - 1
125
		end
126
	  else
127
        if direction then
128
	      posX = posX - 1
129
		else
130
		  posX = posX + 1
131
		end
132
	  end
133
      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
134
	    turtle.turnLeft()
135
		turtle.select(2)
136
		turtle.place()
137
		turtle.turnRight()
138
	  end
139
    end
140
    if j < y then
141
      if direction then
142
        turtle.turnRight()
143
        turtle.dig()
144
        turtle.forward()
145
		posY = posY + 1
146
        turtle.turnRight()
147
        direction = false
148
      else
149
        turtle.turnLeft()
150
        turtle.dig()
151
        turtle.forward()
152
		posY = posY + 1
153
        turtle.turnLeft()
154
        direction = true
155
      end
156
    end
157
	if(turtle.getItemCount(16) > 0) then
158
		goUnload(direction, inventory_start)
159
	end
160
  end	
161
  if i < z then
162
    turtle.digUp()
163
    turtle.up()
164
	posZ = posZ + 1
165
    turtle.turnRight()
166
    turtle.turnRight()
167
  end
168
end
169
 
170
171
172
173
if z % 2 == 0 then
174
  for i = 1, z do
175
    turtle.down()
176
	posZ = posZ - 1
177
  end
178
  turtle.turnRight()
179
  for inventory = inventory_start, 16 do
180
    turtle.select(inventory)
181
    turtle.drop()
182
  end
183
  turtle.turnRight()
184
else
185
  if y % 2 == 0 then
186
    turtle.turnRight()
187
    for i = 1, y-1 do
188
      turtle.forward()
189
	  posY = posY - 1
190
    end
191
	for i = 1, z do
192
      turtle.down()
193
	  posZ = posZ - 1
194
    end
195
    for inventory = inventory_start, 16 do
196
      turtle.select(inventory)
197
      turtle.drop()
198
    end
199
    turtle.turnRight()
200
  else
201
    turtle.turnLeft()
202
    for i = 1, y-1 do
203
      turtle.forward()
204
      posY = posY - 1
205
    end
206
    turtle.turnLeft()
207
    for i = 1, x-1 do
208
      turtle.forward()
209
	  posX = posX - 1
210
    end
211
    for i = 1, z do
212
      turtle.down()
213
      posZ = posZ - 1
214
    end
215
    turtle.turnRight()
216
    for inventory = inventory_start, 16 do
217
      turtle.select(inventory)
218
      turtle.drop()
219
    end
220
    turtle.turnRight()
221
  end
222
end