Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local currentDirection = nil
- function getCurrentDirection()
- local blockStatus, blockData = turtle.inspect()
- if (blockStatus == false)
- then
- local tp1X, tp1Y, tp1Z = gps.locate()
- turtle.forward()
- local tp2X, tp2Y, tp2Z = gps.locate()
- turtle.back()
- if (tp1X == tp2X)
- then
- if (tp1Z < tp2Z)
- then
- currentDirection = "South"
- else
- currentDirection = "North"
- end
- else
- if (tp1X < tp2X)
- then
- currentDirection = "East"
- else
- currentDirection = "West"
- end
- end
- else
- turnLeft()
- getCurrentDirection()
- end
- end
- getCurrentDirection()
- print("Direction: "..currentDirection)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement