Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --variables
- local currentHeight
- local endHeight
- local currentNS
- local endNS
- local currentWE
- local endWE
- local tempHeight
- local tempNS
- local tempWE
- local currentDirection = 'n'
- local endDirection
- local ladderSelection = 'n'
- local tunnelSelection = 'n'
- local ladderTorch = 0
- local tunnelTorch = 0
- --functions
- function return()
- tempHeight = currentHeight
- currentHeight = endHeight
- endHeight = tempHeight
- tempNS =endNS
- currentNS = endNS
- endNS = tempNS
- tempWE = currentWE
- currentWE = endWE
- endWE = tempWE
- function tunnels()
- turtle.digUp()
- turtle.digDown()
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.dig()
- tunnelTorch = tunnelTorch +1
- local placeTorch = tunnelTorch%10
- if placeTorch ==1 then
- turtle.select(2)
- turtle.place()
- end
- turtle.digDown()
- turtle.back()
- turtle.turnRight()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.dig()
- turtle.digDown()
- turtle.back()
- turtle.turnLeft()
- end
- function ladders()
- local blockFront = turtle.detect()
- if blockFront == true then
- turtle.select(1)
- turtle.dig()
- turtle.place()
- ladderTorch = ladderTorch +1
- local placeTorch = ladderTorch%5
- if placeTorch ==1 then
- turtle.turnLeft()
- turtle.dig()
- turtle.select(2)
- turtle.place()
- turtle.turnRight()
- end
- end
- end
- function turnRight(c,e)
- turtle.turnRight()
- currentDirection = e
- end
- function turnAround(c,e)
- turtle.turnRight() turtle.turnRight()
- currentDirection = e
- end
- function turnLeft(c,e)
- turtle.turnLeft()
- currentDirection = e
- end
- function compus()
- if (currentDirection == 'n') and (endDirection =='e') then
- turnRight('n','e') end
- if (currentDirection == 'n') and (endDirection =='s') then
- turnAround('n','s') end
- if (currentDirection == 'n') and (endDirection =='w') then
- turnLeft('n','w') end
- if (currentDirection == 'e') and (endDirection =='s') then
- turnRight('e','s') end
- if (currentDirection == 'e') and (endDirection =='w') then
- turnAround('e','w') end
- if (currentDirection == 'e') and (endDirection =='n') then
- turnLeft('e','n') end
- if (currentDirection == 's') and (endDirection =='w') then
- turnRight('s','w') end
- if (currentDirection == 's') and (endDirection =='n') then
- turnAround('s','n') end
- if (currentDirection == 's') and (endDirection =='e') then
- turnLeft('s','e') end
- if (currentDirection == 'w') and (endDirection =='n') then
- turnRight('w','n') end
- if (currentDirection == 'w') and (endDirection =='e') then
- turnAround('w','e') end
- if (currentDirection == 'w') and (endDirection =='s') then
- turnLeft('w','s') end
- end
- function moveHeight()
- if currentHeight<endHeight then
- local blockUp = turtle.detectUp()
- if ladderSelection == 'y' then
- ladders() end
- if blockUp == false then
- turtle.up()
- else
- turtle.digUp()
- turtle.up()
- end
- currentHeight = currentHeight + 1
- end
- if currentHeight>endHeight then
- local blockDown = turtle.detectDown()
- if ladderSelection == 'y' then
- ladders() end
- if blockDown == false then
- turtle.down()
- else
- turtle.digDown()
- turtle.down()
- end
- currentHeight = currentHeight - 1
- end
- end
- function moveNS()
- if currentNS>endNS then
- endDirection = 'n'
- compus()
- local blockFront = turtle.detect()
- if blockFront == true then
- turtle.dig()
- if tunnelSelection == 'y' then
- tunnels() end
- turtle.forward()
- else
- turtle.forward()
- end
- currentNS = currentNS -1
- end
- if currentNS<endNS then
- endDirection = 's'
- compus()
- local blockFront = turtle.detect()
- if blockFront == true then
- turtle.dig()
- if tunnelSelection == 'y' then
- tunnels() end
- turtle.forward()
- else
- turtle.forward()
- end
- currentNS = currentNS +1
- end
- end
- function moveWE()
- if currentWE>endWE then
- endDirection = 'w'
- compus()
- local blockFront = turtle.detect()
- if blockFront == true then
- turtle.dig()
- if tunnelSelection == 'y' then
- tunnels() end
- turtle.forward()
- else
- turtle.forward()
- end
- currentWE = currentWE -1
- end
- if currentWE<endWE then
- endDirection = 'e'
- compus()
- local blockFront = turtle.detect()
- if blockFront == true then
- turtle.dig()
- if tunnelSelection == 'y' then
- tunnels() end
- turtle.forward()
- else
- turtle.forward()
- end
- currentWE = currentWE +1
- end
- end
- --main
- print("what direction is the turtle Facing? n/s/e/w:")
- currentDirection = read()
- print("Slot 2:Torches")
- write("do you want ladders?:")
- ladderSelection = read()
- if ladderSelection = 'y' then
- print("Slot 1:Ladders")
- print("Slot 2:Torches")
- end
- write("do you want tunnels?:")
- tunnelSelection = read()
- if tunnelSelection = 'y' then
- print("Slot 2:Torches")
- end
- print("Whats the Turtles current position?")
- write("x:") currentWE = tonumber(read())
- write("z:") currentNS = tonumber(read())
- write("y:") currentHeight = tonumber(read())
- print("Whats the Turtles end position?:")
- write("x:") endWE = tonumber(read())
- write("z:") endNS = tonumber(read())
- write("y:") endHeight = tonumber(read())
- repeat
- moveHeight()
- until currentHeight == endHeight
- repeat
- moveNS()
- until currentNS == endNS
- repeat
- moveWE()
- until currentWE == endWE
- return()
- repeat
- moveWE()
- until currentWE == endWE
- repeat
- moveNS()
- until currentNS == endNS
- repeat
- moveHeight()
- until currentHeight == endHeight
- endDirection = 'n'
- compus()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement