Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- if #args ~= 3 then
- print("Uso: "..shell.getRunningProgram().." <largura> <altura> <profundidade>")
- return
- end
- local needsFuel = turtle.getFuelLimit() ~= "unlimited"
- local function refuel()
- if needsFuel then
- for i=16,1,-1 do
- turtle.select(i)
- turtle.refuel()
- end
- end
- end
- local directions = {north=0, east=1, south=2, west=-1}
- local direction = directions.north
- local function turn(newDirection)
- if direction == newDirection then
- return
- end
- local turnRelative = direction > 0 and turtle.turnLeft or turtle.turnRight
- local turns = math.abs(newDirection - direction)
- for i=1,turns do
- turnRelative()
- end
- direction = newDirection
- end
- local function forward(n)
- n = n or 1
- for i=1,n do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- end
- end
- local x = tonumber(args[1])
- local y = tonumber(args[2])-1
- local z = tonumber(args[3])
- term.clear()
- term.setCursorPos(1,1)
- print(string.format("Largura: %s \nAltura: %s \nProfundidade: %s",x,y+1,z))
- local primary = x >= z and x or z
- local secondary x >= z and z or x
- direction = x >= z and directions.east or directions.north
- for i=1,secondary do
- for i=1,primary do
- for i=1,y do
- turn(direction)
- while turtle.detect() do
- turtle.dig()
- end
- if i ~= y do
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- turtle.up()
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
RAW Paste Data