Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Load Current Coordinates
- local file = fs.open("coord", "r")
- local cCoord = file.readAll()
- file.close()
- cCoord = textutils.unserialize(cCoord)
- function cS()
- term.clear()
- term.setCursorPos(1,1)
- end
- --Get Desired Coordinates
- local flag
- local nCoord = {x, y, z, dir}
- repeat
- print("Enter X Coords: ")
- nCoord.x = io.read()
- print("")
- print("Enter Z Coords: ")
- nCoord.z = io.read()
- print("")
- print("What Direction Is Turtle Facing?: ")
- nCoord.dir = io.read()
- print("")
- print("Are These Correct? Y/N: ")
- flag = io.read()
- string.lower(flag)
- cS()
- until flag == "y"
- --Compare coords
- local pCoord = {x, z}
- pCoord.x = cCoord.x - nCoord.x
- pCoord.z = cCoord.z - nCoord.z
- --Travel Y
- for i = 1,30 do
- turtle.up()
- end
- cCoord.y = cCoord.y + 30
- --Travel X
- if nCoord.dir == "east" then
- if pCoord.x < 0 then
- pCoord.x = pCoord.x * -1
- for i = 1,pCoord.x do
- turtle.forward()
- end
- else
- for i = 1,pCoord.x do
- turtle.back()
- end
- end
- elseif nCoord.dir == "south" then
- if pCoord.x < 0 then
- pCoord.x = pCoord.x * -1
- turtle.turnLeft()
- for i = 1,pCoord.x do
- turtle.forward()
- end
- turtle.turnRight()
- else
- turtle.turnRight()
- for i = 1,pCoord.x do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- elseif nCoord.dir == "west" then
- if pCoord.x < 0 then
- pCoord.x = pCoord.x * -1
- for i = 1,pCoord.x do
- turtle.back()
- end
- else
- for i = 1,pCoord.x do
- turtle.forward()
- end
- end
- elseif nCoord.dir == "north" then
- if pCoord.x < 0 then
- pCoord.x = pCoord.x * -1
- turtle.turnRight()
- for i = 1,pCoord.x do
- turtle.forward()
- end
- turtle.turnLeft()
- else
- turtle.turnLeft()
- for i = 1,pCoord.x do
- turtle.forward()
- end
- end
- end
- --Travel Z
- if nCoord.dir == "east" then
- if pCoord.z < 0 then
- pCoord.z = pCoord.z * -1
- turtle.turnRight()
- for i = 1,pCoord.z do
- turtle.forward()
- end
- turtle.turnLeft()
- else
- turtle.turnLeft()
- for i = 1,pCoord.z do
- turtle.forward()
- end
- turtle.turnRight()
- end
- elseif nCoord.dir == "south" then
- if pCoord.z < 0 then
- pCoord.z = pCoord.z * -1
- for i = 1,pCoord.z do
- turtle.forward()
- end
- else
- for i = 1,pCoord.z do
- turtle.back()
- end
- end
- elseif nCoord.dir == "west" then
- if pCoord.z < 0 then
- pCoord.z = pCoord.z * -1
- turtle.turnLeft()
- for i = 1,pCoord.z do
- turtle.forward()
- end
- turtle.turnRight()
- else
- turtle.turnRight()
- for i = 1,pCoord.z do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- elseif nCoord.dir == "north" then
- if pCoord.z < 0 then
- pCoord.z = pCoord.z * -1
- for i = 1,pCoord.z do
- turtle.back()
- end
- else
- for i = 1,pCoord.z do
- turtle.forward()
- end
- end
- end
- --Down Y
- local yFlag = 0
- repeat
- turtle.down()
- yFlag = yFlag + 1
- until turtle.detectDown()
- cCoord.y = cCoord.y - yFlag
- --Save New Coords
- cCoord.x = nCoord.x
- cCoord.z = nCoord.z
- fs.delete("coord")
- local file = fs.open("coord", "w")
- file.write(textutils.serialize(cCoord))
- file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement