Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lengthMax = 4
- widthMax = 4
- heightMax = 5
- turn = 1
- turnLast = turn
- lengthCurrent = lengthMax
- placeTorch = 10
- width = widthMax
- finishWalk = widthMax
- heightMax = heightMax - 3
- height = heightMax
- ending = false
- kill = false
- function left()
- turtle.turnLeft()
- end
- function right()
- turtle.turnRight()
- end
- function moveForward()
- while turtle.detect() do
- turtle.dig()
- end
- moved = false
- while not(moved) do
- moved = turtle.forward()
- end
- end
- function digForward()
- while turtle.detect() do
- turtle.dig()
- end
- end
- function digBelow()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- function digAbove()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- function moveUp()
- turtle.digUp()
- moved = false
- while not(moved) do
- turtle.up()
- moved = turtle.up()
- end
- end
- function goDown()
- turtle.down()
- end
- function goUp()
- turtle.up()
- end
- function moveDown()
- turtle.digDown()
- moved = false
- while not(moved) do
- moved = turtle.down()
- end
- end
- function upBreak()
- digAbove()
- goUp()
- digAbove()
- end
- function leftDig()
- turtle.turnLeft()
- moveForward()
- digAbove()
- digBelow()
- while height > 0 do
- upBreak()
- height = height - 1
- end
- height = heightMax
- while height > 0 do
- moveDown()
- height = height - 1
- end
- height = heightMax
- turtle.turnLeft()
- end
- function rightDig()
- turtle.turnRight()
- moveForward()
- digAbove()
- digBelow()
- while height > 0 do
- upBreak()
- height = height - 1
- end
- height = heightMax
- while height > 0 do
- moveDown()
- height = height - 1
- end
- height = heightMax
- turtle.turnRight()
- end
- function leftWalk()
- turtle.turnLeft()
- moveForward()
- digAbove()
- digBelow()
- while height > 0 do
- upBreak()
- height = height - 1
- end
- height = heightMax
- while height > 0 do
- moveDown()
- height = height - 1
- end
- height = heightMax
- end
- function rightWalk()
- turtle.turnRight()
- moveForward()
- digAbove()
- digBelow()
- while height > 0 do
- upBreak()
- height = height - 1
- end
- height = heightMax
- while height > 0 do
- moveDown()
- height = height - 1
- end
- height = heightMax
- end
- while true do
- if lengthCurrent > 0 and ending == false then
- moveForward()
- digAbove()
- digBelow()
- while height > 0 do
- upBreak()
- height = height - 1
- end
- height = heightMax
- while height > 0 do
- moveDown()
- height = height - 1
- end
- height = heightMax
- placeTorch = placeTorch - 1
- lengthCurrent = lengthCurrent - 1
- if placeTorch <= 0 then
- placeTorch = 10
- turtle.placeDown()
- end
- end
- if lengthCurrent <= 0 and turn == 1 and width > 0 then
- width = width - 1
- if width > 0 then
- rightDig()
- lengthCurrent = lengthMax
- turn = 2
- print("Turned Right")
- end
- end
- if lengthCurrent <= 0 and turn == 2 and width > 0 then
- width = width - 1
- if width > 0 then
- leftDig()
- lengthCurrent = lengthMax
- turn = 1
- print("Turned Left")
- end
- end
- if width <= 0 then
- turnLast = turn
- turn = 3
- ending = true
- end
- if width <= 0 and turn == 3 and ending == true then
- print("Final Walk Home")
- if turnLast == 1 then
- lengthCurrent = lengthMax
- left()
- finishWalk = finishWalk - 1
- while finishWalk > 0 do
- moveForward()
- finishWalk = finishWalk - 1
- end
- while lengthCurrent > 0 do
- moveForward()
- lengthCurrent = lengthCurrent - 1
- end
- end
- if turnLast == 2 then
- right()
- finishWalk = finishWalk - 1
- while finishWalk > 0 do
- moveForward()
- finishWalk = finishWalk - 1
- end
- right()
- end
- kill = true
- turn = 4
- end
- if kill == true then
- print("Killing the Program")
- error()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement