Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1,1)
- repeat
- print("Enter tunnel Length (even number): ")
- length = read()
- print("Enter height (even number): ")
- height = read()
- print("Enter Width (even number): ")
- width = read()
- until length % 2 == 0
- term.clear()
- while turtle.getItemCount(1) == 0 do
- print("Place fuel in slot 1.")
- read()
- end
- while turtle.getItemCount(2) == 0 do
- print("Place torches in slot 2.")
- read()
- end
- print("Place chest behind turtle.\n")
- term.clear()
- print("Here we go!")
- torchpos = 0
- function fuel()
- if turtle.getFuelLevel() < 0.26 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- function mine()
- local LoopHeight = 0
- local LoopWidth = 0
- local LoopLength = 0
- fuel()
- --odd numbers left even numbers right
- for LoopLength = 0, length - 1 do
- for LoopHeight = 0, height - 1 do
- if LoopHeight % 2 == 0 then
- turtle.turnLeft()
- if LoopLength > 1 then
- print("LoopLength: ", LoopLength)
- print("LoopHeight: ", LoopHeight)
- print("Width: ", width)
- read()
- end
- for LoopWidth = 0, width -2 do
- leftDown()
- --print("LoopWidthL: ", LoopWidth)
- end
- if LoopHeight == height - 1 then
- endHeightCheck(LoopWidth, LoopLength)
- end
- turtle.turnRight()
- else
- turtle.turnRight()
- for LoopWidth = 0, width -2 do
- rightDown()
- --print("LoopWidthR: ", LoopWidth)
- end
- if LoopHeight == height - 1 then
- endHeightCheck(LoopWidth, LoopLength)
- end
- turtle.turnLeft()
- end
- if LoopHeight ~= height - 1 then
- if LoopLength % 2 == 0 then
- checkEmptyDown()
- else
- checkEmptyUp()
- end
- end
- end
- if LoopLength % 2 == 0 then
- turtle.turnRight()
- print("Length check Right: ")
- read()
- else
- turtle.turnLeft()
- print("Length check left: ")
- read()
- end
- end
- end
- function checkEmptySpace()
- while turtle.detect() == true do
- turtle.dig()
- end
- end
- function leftDown()
- checkEmptySpace()
- turtle.forward()
- end
- function rightDown()
- checkEmptySpace()
- turtle.forward()
- end
- function checkEmptyDown()
- if turtle.detectDown() == true then
- turtle.digDown()
- end
- turtle.down()
- end
- function checkEmptyUp()
- if turtle.detectUp() == true then
- turtle.digUp()
- end
- turtle.up()
- end
- function endHeightCheck(LoopWidth, LoopLength)
- if LoopLength % 2 == 0 then
- if LoopWidth % 2 == 1 then
- turtle.turnRight()
- checkEmptySpace()
- turtle.forward()
- else
- turtle.turnLeft()
- checkEmptySpace()
- turtle.forward()
- end
- else
- if LoopWidth % 2 == 0 then
- turtle.turnRight()
- checkEmptySpace()
- turtle.forward()
- else
- turtle.turnLeft()
- checkEmptySpace()
- turtle.forward()
- end
- end
- end
- mine()
Advertisement
Add Comment
Please, Sign In to add comment