Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xCurrent = 0
- zCurrent = 0
- yCurrent = 0
- xHome = 0
- zHome = 0
- yHome = 0
- orientation = 4
- orientations = {"north", "east", "south", "west"}
- startDirection = orientation
- zDiff = {-1, 0, 1, 0}
- xDiff = {0, 1, 0 ,-1}
- function upMove()
- yCurrent = yCurrent + 1
- turtle.up()
- end
- function downMove()
- yCurrent = yCurrent - 1
- turtle.down()
- end
- function forwardMove()
- xCurrent = xCurrent + xDiff[orientation]
- zCurrent = zCurrent + zDiff[orientation]
- turtle.forward()
- end
- function backMove()
- xCurrent = xCurrent - xDiff[orientation]
- zCurrent = zCurrent - zDiff[orientation]
- turtle.back()
- end
- function leftMove()
- orientation = orientation - 1
- orientation = (orientation - 1) % 4
- orientation = orientation + 1
- turtle.turnLeft()
- forwardMove()
- end
- function rightMove()
- orientation = orientation - 1
- orientation = (orientation + 1) % 4
- orientation = orientation + 1
- turtle.turnRight()
- forwardMove()
- end
- function left()
- orientation = orientation - 1
- orientation = (orientation - 1) % 4
- orientation = orientation + 1
- turtle.turnLeft()
- end
- function right()
- orientation = orientation - 1
- orientation = (orientation + 1) % 4
- orientation = orientation + 1
- turtle.turnRight()
- end
- function look(direction)
- while direction ~= orientations[orientation] do
- right()
- end
- end
- function goto(xHome, zHome, yHome)
- while yHome < yCurrent do
- downMove()
- end
- while yHome > yCurrent do
- upMove()
- end
- if xHome < xCurrent then
- look("west")
- while xHome < xCurrent do
- forwardMove()
- end
- end
- if xHome > xCurrent then
- look("east")
- while xHome > xCurrent do
- forwardMove()
- end
- end
- if zHome < zCurrent then
- look("north")
- while zHome < zCurrent do
- forwardMove()
- end
- end
- if zHome > zCurrent then
- look("south")
- while zHome > zCurrent do
- forwardMove()
- end
- end
- while not(orientation == startDirection) do
- right()
- end
- end
- function shearDown()
- while not(turtle.placeDown()) do
- turtle.placeDown()
- turtle.suckUp()
- end
- end
- function dropOff()
- turtle.select(2)
- while turtle.getItemCount() > 0 do
- turtle.drop()
- end
- turtle.select(1)
- end
- function forwardShear()
- forwardMove()
- shearDown()
- end
- function leftShear()
- leftMove()
- shearDown()
- end
- function rightShear()
- rightMove()
- shearDown()
- end
- function startDrop()
- backMove()
- left()
- dropOff()
- end
- function backToStart()
- leftMove()
- leftMove()
- forwardMove()
- left()
- end
- function shearCheck()
- turtle.select(1)
- if turtle.getItemCount() == 0 then
- goto(0, 0, 0)
- end
- end
- function shearThree()
- shearDown()
- shearCheck()
- forwardShear()
- shearCheck()
- forwardShear()
- shearCheck()
- leftMove()
- shearCheck()
- left()
- shearCheck()
- forwardShear()
- shearCheck()
- forwardShear()
- shearCheck()
- rightMove()
- shearCheck()
- right()
- shearCheck()
- forwardShear()
- shearCheck()
- forwardShear()
- shearCheck()
- startDrop()
- shearCheck()
- backToStart()
- shearCheck()
- end
- while true do
- shearThree()
- sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement