Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function directionCheck()
- gpscords = {}
- turtle.equipLeft()
- alphaX, alphaY, alphaZ = gps.locate()
- turtle.equipLeft()
- turtle.dig()
- turtle.forward()
- turtle.equipLeft()
- betaX, betaY, betaZ = gps.locate()
- turtle.equipLeft()
- turtle.back()
- return alphaX, alphaY, alphaZ, betaX, betaY, betaZ
- end
- function pointNorth(newalphaX, newalphaY, newalphaZ, newbetaX, newbetaY, newbetaZ)
- alphaX = newalphaX
- alphaY = newalphaY
- alphaZ = newalphaZ
- betaX = newbetaX
- betaY = newbetaY
- betaZ = newbetaZ
- if betaX > alphaX then
- --positive x direction
- elseif betaX < alphaX then
- --negative x direction
- turtle.turnLeft()
- turtle.turnLeft()
- elseif betaZ > alphaZ then
- --positive z direction
- turtle.turnLeft()
- elseif betaZ < alphaZ then
- --negative z direction
- turtle.turnRight()
- end
- end
- function returnDirection(newalphaX, newalphaY, newalphaZ, newbetaX, newbetaY, newbetaZ)
- alphaX = newalphaX
- alphaY = newalphaY
- alphaZ = newalphaZ
- betaX = newbetaX
- betaY = newbetaY
- betaZ = newbetaZ
- if betaX > alphaX then
- --positive x direction
- return "north"
- elseif betaX < alphaX then
- --negative x direction
- return "south"
- elseif betaZ > alphaZ then
- --positive z direction
- return "west"
- elseif betaZ < alphaZ then
- --negative z direction
- return "east"
- end
- end
- function setDirection(direct)
- if direct == "north" then
- --positive x direction
- elseif direct == "south" then
- --negative x direction
- turtle.turnLeft()
- turtle.turnLeft()
- elseif direct == "west" then
- --positive z direction
- turtle.turnLeft()
- elseif direct == "east" then
- --negative z direction
- turtle.turnRight()
- end
- end
- function lookNorth()
- newalphaX, newalphaY, newalphaZ, newbetaX, newbetaY, newbetaZ = directionCheck()
- pointNorth(newalphaX, newalphaY, newalphaZ, newbetaX, newbetaY, newbetaZ)
- end
- function getDirection()
- alphaX, alphaY, alphaZ, betaX, betaY, betaZ = directionCheck()
- return returnDirection(alphaX, alphaY, alphaZ, betaX, betaY, betaZ)
- end
- function oppDirection(direct)
- if direct == "north" then
- return "south"
- elseif direct == "south" then
- return "north"
- elseif direct == "west" then
- return "east"
- elseif direct == "east" then
- return "west"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement