Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getHeading()
- if(turtle.getFuelLevel() < 2) then
- error("Insufficient fuel")
- end
- local start = vector.new(gps.locate())
- while(turtle.detect()) do
- turtle.dig()
- end
- turtle.forward()
- local current = vector.new(gps.locate())
- turtle.back()
- if(start.z - current.z > 0) then
- heading = 'N'
- elseif (start.z - current.z < 0) then
- heading = 'S'
- end
- if(start.x - current.x > 0) then
- heading = 'W'
- elseif (start.x - current.x < 0) then
- heading = 'E'
- end
- return heading
- end
- print (getHeading())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement