Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- if #tArgs ~= 3 then
- print("Requires length, width, height")
- return
- end
- local x = tonumber(tArgs[1]) - 1
- local y = tonumber(tArgs[2])
- local z = tonumber(tArgs[3])
- local posX = 1
- local posY = 1
- local posZ = 1
- if x == nil or y == nil or z == nil then
- print("Invalid dimensions")
- return
- end
- if x < 0 or y < 0 or z < 0 then
- print("Invalid (negative) dimensions")
- return
- end
- local torch = 0
- inventory_start = 2
- print("Use torches? (y/n)")
- local input = io.read()
- if(input == "y") then
- torch = 2
- inventory_start = 3
- else
- torch = 0
- end
- local roomSize = x * y * z
- print("Storing fuel for mining process...")
- turtle.select(1)
- while turtle.getFuelLevel() < roomSize do
- if not turtle.refuel(1) then
- print("Not enough fuel. Please insert more fuel.")
- return
- end
- end
- --[[Funcao que vai descarregar quando e atingido o ultimo slot]]--
- function goUnload(direction, inventory_start)
- local inventory_start = inventory_start
- if direction then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- if(posZ % 2 == 0) then
- turtle.down()
- end
- for m = 1, posY-1 do
- turtle.forward()
- end
- turtle.turnLeft()
- for m = 1, posX-1 do
- turtle.forward()
- end
- for m = 1, posZ-2 do
- turtle.down()
- end
- turtle.turnRight()
- for inventory = inventory_start, 16 do
- turtle.select(inventory)
- turtle.drop()
- end
- turtle.turnRight()
- for m = 1, posZ-2 do
- turtle.up()
- end
- for m = 1, posX-1 do
- turtle.forward()
- end
- turtle.turnRight()
- for m = 1, posY-1 do
- turtle.forward()
- end
- if direction then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- if(posZ % 2 == 0) then
- turtle.up()
- end
- turle.select(inventory_start)
- end
- local direction = true
- for i = 1, z do
- roomSize = x * y * (z-i)
- while turtle.getFuelLevel() < roomSize do
- turtle.select(1)
- turtle.refuel(1)
- end
- for j = 1, y do
- for k = 1, x do
- turtle.dig()
- turtle.forward()
- if direction then
- posX = posX + 1
- else
- posX = posX - 1
- end
- 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
- turtle.turnLeft()
- turtle.select(2)
- turtle.place()
- turtle.turnRight()
- end
- end
- if j < y then
- if direction then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- posY = posY + 1
- turtle.turnRight()
- direction = false
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- posY = posY + 1
- turtle.turnLeft()
- direction = true
- end
- end
- if(turtle.getItemCount(16) > 0) then
- goUnload(direction, inventory_start)
- end
- end
- if i < z then
- turtle.digUp()
- turtle.up()
- posZ = posZ + 1
- turtle.turnRight()
- turtle.turnRight()
- if direction then
- direction = false
- else
- direction = true
- end
- end
- end
- if z % 2 == 0 then
- for i = 1, z do
- turtle.down()
- posZ = posZ - 1
- end
- turtle.turnRight()
- for inventory = inventory_start, 16 do
- turtle.select(inventory)
- turtle.drop()
- end
- turtle.turnRight()
- else
- if y % 2 == 0 then
- turtle.turnRight()
- for i = 1, y-1 do
- turtle.forward()
- posY = posY - 1
- end
- for i = 1, z do
- turtle.down()
- posZ = posZ - 1
- end
- for inventory = inventory_start, 16 do
- turtle.select(inventory)
- turtle.drop()
- end
- turtle.turnRight()
- else
- turtle.turnLeft()
- for i = 1, y-1 do
- turtle.forward()
- posY = posY - 1
- end
- turtle.turnLeft()
- for i = 1, x-1 do
- turtle.forward()
- posX = posX - 1
- end
- for i = 1, z do
- turtle.down()
- posZ = posZ - 1
- end
- turtle.turnRight()
- for inventory = inventory_start, 16 do
- turtle.select(inventory)
- turtle.drop()
- end
- turtle.turnRight()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement