Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- function goto(X, Y, Z)
- dir = getDirFacing()
- cX, cY, cZ = gps.locate(10)
- upFirst = true
- if Y < cY then
- upFirst = false
- end
- dirsTried = 0
- while dir == "?" do
- if upFirst and turtle.detectUp() then
- upFirst = false
- dirsTried = dirsTried + 1
- elseif not upFirst and turtle.detectDown() then
- upFirst = true
- dirsTried = dirsTried + 1
- end
- if dirsTried == 2 then
- return false
- end
- if upFirst then
- sUp()
- else
- sDown()
- end
- dir = getDirFacing()
- end
- stack = {}
- cX, cY, cZ = gps.locate(10)
- end
- function getDirFacing()
- cX, cY, cZ = gps.locate(10)
- turnCount = 0
- while not (sForward() == 1) do
- turn("right")
- turnCount = turnCount + 1
- if turnCount >= 4 then
- return "?"
- end
- end
- nX, nY, nZ = gps.locate(10)
- if nX ~= cX then
- if nX > cX then
- return "+x"
- else
- return "-x"
- end
- elseif nZ ~= cZ then
- if nZ > cZ then
- return "+z"
- else
- return "-z"
- end
- end
- return "?"
- end
Advertisement
Add Comment
Please, Sign In to add comment