Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---@diagnostic disable: undefined-global
- function startAll()
- print("cual es tu anchura")
- local ancho = read()
- ancho = tonumber(ancho)
- while checkCorrectDataType(ancho) do
- print("--------------------------------")
- print("tu anchura tiene que ser un numero")
- print("cual es tu anchura")
- print("--------------------------------")
- ancho = read()
- ancho = tonumber(ancho)
- end
- print("cual es tu largo")
- local largo = read()
- largo = tonumber(largo)
- while checkCorrectDataType(largo) do
- print("--------------------------------")
- print("tu largo tiene que ser un numero")
- print("cual es tu largo")
- print("--------------------------------")
- largo = read()
- largo = tonumber(largo)
- end
- print("cual es tu altura")
- local alto = read()
- alto = tonumber(alto)
- while checkCorrectDataType(alto) do
- print("--------------------------------")
- print("tu altura tiene que ser un numero")
- print("cual es tu altura")
- print("--------------------------------")
- alto = read()
- alto = tonumber(alto)
- end
- dig3d(ancho, largo, alto)
- end
- function dig3d(ancho, largo, alto)
- local currentLayer = 0
- local anchoInicial = ancho
- for i = 1, alto, 1 do
- dig2d(largo, ancho, currentLayer, anchoInicial)
- turtle.digUp()
- turtle.up()
- currentLayer = currentLayer + 1
- end
- for i = alto, 1, -1 do
- turtle.down()
- end
- end
- function checkCorrectDataType(input)
- return input == nil
- end
- function resetPosition(ancho, largo)
- if ancho % 2 == 0 then
- turtle.turnRight()
- for i = 1, ancho, 1 do
- turtle.forward()
- end
- turtle.turnRight()
- else
- turtle.turnLeft()
- for i = 1, ancho, 1 do
- turtle.forward()
- end
- turtle.turnRight()
- for i = 1, largo, 1 do
- turtle.back()
- end
- end
- end
- -- working good
- function dig2d(largo, ancho, currentLayer, anchoInicial)
- local temp = ancho
- primeraMinada = ancho
- while temp > 0 do
- if temp == primeraMinada then
- digLargo(largo, currentLayer, anchoInicial, temp)
- else
- giro()
- digLargo(largo - 1, currentLayer, anchoInicial, temp)
- end
- temp = temp - 1
- end
- resetPosition(ancho, largo)
- end
- -- working always
- function giro()
- turtle.turnRight()
- if turtle.detect() == true then
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnRight()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- -- working good
- function digLargo(largo, currentLayer, anchoInicial, temp)
- while largo > 0 do
- if turtle.detect() == false then
- turtle.forward()
- largo = largo - 1
- else
- turtle.dig()
- end
- end
- end
- startAll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement