Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkFuel()
- currentFuel = turtle.getFuelLevel()
- currentSlot = turtle.getSelectedSlot()
- if turtle.getFuelLevel() < 1 then
- for slot = 1,16 do
- if turtle.refuel() then
- return true, "Fueled"
- elseif slot == 16 then
- return false, "No fuel left"
- end
- end
- else
- print("there is still "..currentFuel.." Fuel left")
- return false
- end
- end
- checkFuel()
- function askLenght()
- print("Choose the lenght of the cave")
- term.write("enter a number between 1-10: ")
- caveLenght = tonumber(read())
- if caveLenght == nil or caveLenght == string then
- print("Please enter a valid value")
- askLenght()
- elseif caveLenght < 1 or caveLenght > 10 then
- print("Number must be between 1-10")
- askLenght()
- else
- print("Cavelenght = "..caveLenght)
- end
- end
- function askWide()
- print("Choose the Wide of the cave")
- term.write("enter a number between 1-10: ")
- caveWide = tonumber(read())
- if caveWide == nil or caveWide == string then
- print("Please enter a valid value")
- askWide()
- elseif caveWide < 1 or caveWide > 10 then
- print("Number must be between 1-10")
- askWide()
- else
- print("CaveWide = "..caveWide)
- end
- end
- function askDepth()
- print("Choose the depth of the cave")
- term.write("enter a number between 1-10: ")
- caveDepth = tonumber(read())
- if caveDepth == nil or caveDepth == string then
- print("Please enter a valid value")
- askDepth()
- elseif caveDepth < 1 or caveDepth > 10 then
- print("Number must be between 1-10")
- askDepth()
- else print("Cavedepth = "..caveDepth)
- end
- end
- function cave()
- checkFuel()
- print("Making a cave "..caveLenght.." long "..caveWide.." wide "..caveDepth.." deep ")
- for depth = 1, caveDepth do
- turtle.digDown()
- turtle.down()
- checkFuel()
- for wide = 1, caveWide do
- for lenght = 1, caveLenght do
- turtle.dig()
- turtle.forward()
- end
- if wide %2 == 0 and wide < caveWide then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- elseif wide %2 ~= 0 and wide < caveWide then
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- if caveWide % 2 == 0 then
- turtle.turnLeft()
- for backWideeven = 1, caveWide do
- turtle.forward()
- end
- turtle.turnLeft()
- elseif caveWide == 1 then
- for backoneLenght = 1, caveLenght() do
- turtle.back()
- end
- elseif caveWide % 2 ~= 0 then
- for backLenght = 1,caveLenght do
- turtle.back()
- end
- turtle.turnRight()
- for backWide = 1,caveWide do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- if depth == caveDepth then
- for backup = 1, caveDepth do
- turtle.up()
- end
- end
- end
- end
- askLenght()
- askWide()
- askDepth()
- cave()
Add Comment
Please, Sign In to add comment