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