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