Advertisement
melzneni

quarry_computerStartup

Mar 19th, 2020
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. local c=false
  2. while not peripheral.isPresent("top") do
  3. if not c then print("no modem connected")end
  4. sleep(3)
  5. c=true
  6. end
  7. function host()
  8. local x, y, z = gps.locate()
  9. if x == nil then error("fail") end
  10. shell.run("remove", "gpsData")
  11. local f = fs.open("gpsData", "w")
  12. f.write(x .. "," .. y .. "," .. z)
  13. f.close()
  14. shell.run("gps", "host", x, y, z)
  15. end
  16.  
  17. local status, msg = pcall(host)
  18. if not status then
  19. print(string.sub(msg, #msg - 3) == "fail")
  20. print("err: " .. msg)
  21. print("using stored position...")
  22. local f = fs.open("gpsData", "r")
  23. local txt = f.readAll()
  24. f.close()
  25. local i = string.find(txt, ",")
  26. local x = tonumber(string.sub(txt, 1, i - 1))
  27. txt = string.sub(txt, i + 1)
  28. local i = string.find(txt, ",")
  29. local y = tonumber(string.sub(txt, 1, i - 1))
  30. txt = string.sub(txt, i + 1)
  31. local z = tonumber(txt)
  32. shell.run("gps", "host", x, y, z)
  33. end
  34.  
  35. --[[
  36. pastebin run 0YB9PsQV startup={files={computerStartup=<pb:18C6DCQU>,cmds={{'computerStartup'}}}} reboot=true label=<input:'Label'>
  37. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement