Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local c=false
- while not peripheral.isPresent("top") do
- if not c then print("no modem connected")end
- sleep(3)
- c=true
- end
- function host()
- local x, y, z = gps.locate()
- if x == nil then error("fail") end
- shell.run("remove", "gpsData")
- local f = fs.open("gpsData", "w")
- f.write(x .. "," .. y .. "," .. z)
- f.close()
- shell.run("gps", "host", x, y, z)
- end
- local status, msg = pcall(host)
- if not status then
- print(string.sub(msg, #msg - 3) == "fail")
- print("err: " .. msg)
- print("using stored position...")
- local f = fs.open("gpsData", "r")
- local txt = f.readAll()
- f.close()
- local i = string.find(txt, ",")
- local x = tonumber(string.sub(txt, 1, i - 1))
- txt = string.sub(txt, i + 1)
- local i = string.find(txt, ",")
- local y = tonumber(string.sub(txt, 1, i - 1))
- txt = string.sub(txt, i + 1)
- local z = tonumber(txt)
- shell.run("gps", "host", x, y, z)
- end
- --[[
- pastebin run 0YB9PsQV startup={files={computerStartup=<pb:18C6DCQU>,cmds={{'computerStartup'}}}} reboot=true label=<input:'Label'>
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement