SHOW:
|
|
- or go back to the newest paste.
| 1 | local xIni, yIni, zIni | |
| 2 | local xCur, yCur, zCur | |
| 3 | local fCur | |
| 4 | local posOut | |
| 5 | ||
| 6 | xIni, yIni, zIni = gps.locate(5) | |
| 7 | ||
| 8 | if not xIni or not yIni or not zIni then | |
| 9 | print("No or insufficient GPS hosts found")
| |
| 10 | - | close() |
| 10 | + | do return end |
| 11 | end | |
| 12 | ||
| 13 | while not turtle.forward() do | |
| 14 | while not turtle.up() do | |
| 15 | turtle.digUp() | |
| 16 | end | |
| 17 | end | |
| 18 | ||
| 19 | xCur, yCur, zCur = gps.locate(5) | |
| 20 | if zCur > zIni then | |
| 21 | fCur = 0 | |
| 22 | elseif xCur < xIni then | |
| 23 | fCur = 1 | |
| 24 | elseif zCur < zIni then | |
| 25 | fCur = 2 | |
| 26 | elseif xCur > xIni then | |
| 27 | fCur = 3 | |
| 28 | else | |
| 29 | exit() | |
| 30 | end | |
| 31 | ||
| 32 | while not turtle.back() do | |
| 33 | while not turtle.up() do | |
| 34 | turtle.digUp() | |
| 35 | end | |
| 36 | end | |
| 37 | ||
| 38 | xCur, yCur, zCur = gps.locate(5) | |
| 39 | ||
| 40 | if not fs.isDir("data") then
| |
| 41 | fs.delete("data")
| |
| 42 | fs.makeDir("data")
| |
| 43 | end | |
| 44 | ||
| 45 | posOut = io.open("data/pos.txt", "w")
| |
| 46 | posOut:write(textutils.serialize({xCur, yCur, zCur, fCur}))
| |
| 47 | posOut:close() |