Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getDir(compass)
- compass = peripheral.find("compass")
- dir = compass.getFacing()
- return dir
- end
- function getCoords()
- coords = {}
- xFile = fs.open("coords/x", "r")
- coords[1] = xFile.readAll()
- xFile.close()
- yFile = fs.open("coords/y", "r")
- coords[2] = yFile.readAll()
- yFile.close()
- zFile = fs.open("coords/z", "r")
- coords[3] = zFile.readAll()
- zFile.close()
- return coords
- end
- function writeCoords(coords)
- xFile = fs.open("coords/x", "w")
- coords[1] = xFile.write(coords[1])
- xFile.close()
- yFile = fs.open("coords/y", "w")
- coords[2] = yFile.write(coords[2])
- yFile.close()
- zFile = fs.open("coords/z", "w")
- coords[3] = zFile.write(coords[3])
- zFile.close()
- end
- function left()
- turtle.turnLeft()
- dir = turtleCar.getDir()
- end
- function right()
- turtle.turnRight()
- dir = turtleCar.getDir()
- end
- function forward(num)
- while (num > 0) do
- if turtle.forward() then
- if dir == "north" then
- -- coords[3] = coords[3] - 1
- elseif dir == "south" then
- -- coords[3] = coords[3] + 1
- elseif dir == "east" then
- -- coords[1] = coords[1] + 1
- elseif dir == "west" then
- -- coords[1] = coords[1] - 1
- end
- end
- num = num - 1
- end
- end
- function backward(num)
- while (num > 0) do
- if turtle.back() then
- if dir == "north" then
- -- coords[3] = coords[3] + 1
- elseif dir == "south" then
- -- coords[3] = coords[3] - 1
- elseif dir == "east" then
- -- coords[1] = coords[1] - 1
- elseif dir == "west" then
- -- coords[1] = coords[1] + 1
- end
- end
- num = num - 1
- end
- end
- function up()
- if turtle.up() then
- -- coords[2] = coords[2] + 1
- end
- end
- function down()
- if turtle.down() then
- -- coords[2] = coords[2] - 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement