Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- peripheral.wrap("right")
- local tArgs = {...}
- local file = fs.open("save", "r")
- local y = file.readAll()
- file.close()
- if tArgs[1] == nil then tArgs[1] = 1 end
- function legs()
- for i = 1, y do
- turtle.forward()
- end
- turtle.turnLeft()
- y = y + 32
- end
- function locate()
- local xIni, yIni, zIni
- local xCur, yCur, zCur
- local fCur
- local posOut
- xIni, yIni, zIni = gps.locate(5)
- if not xIni or not yIni or not zIni then
- print("No or insufficient GPS hosts found")
- do return end
- end
- while not turtle.forward() do
- while not turtle.up() do
- turtle.digUp()
- end
- end
- xCur, yCur, zCur = gps.locate(5)
- if zCur > zIni then
- fCur = 0
- elseif xCur < xIni then
- fCur = 1
- elseif zCur < zIni then
- fCur = 2
- elseif xCur > xIni then
- fCur = 3
- else
- exit()
- end
- while not turtle.back() do
- while not turtle.up() do
- turtle.digUp()
- end
- end
- xCur, yCur, zCur = gps.locate(5)
- if not fs.isDir("data") then
- fs.delete("data")
- fs.makeDir("data")
- end
- posOut = io.open("data/pos.txt", "w")
- posOut:write(textutils.serialize({xCur, yCur, zCur, fCur}))
- posOut:close()
- end
- function whole()
- for i = 1, 4 do
- legs()
- end
- -- file = io.open("save" , "w")
- -- file:write(textutils.serialize({y}))
- -- file.close()
- end
- for i = 1, tArgs[1] do
- whole()
- locate()
- end
Advertisement
Add Comment
Please, Sign In to add comment