Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function FindOrEnterVar(FileName,Stri)
- local file = fs.open(FileName, "r")
- if not file then
- printError("No "..Stri.." found please enter "..Stri)
- Return = read()
- local file = fs.open(FileName, "w")
- file.write(Return)
- file.close()
- else
- Return = file.readAll()
- file.close()
- end
- return Return
- end
- local GPSFreq = textutils.unserialise(FindOrEnterVar("GPSFreq.txt","GPS frequency 0-65535"))
- local Modem = peripheral.find("modem")
- if not Modem then
- printError("No modem found")
- return false
- end
- Modem.open(GPSFreq)
- if not Modem.isOpen(GPSFreq) then
- printError("Cound not open gps freq")
- return false
- end
- local Pos
- local file = fs.open("Location.txt", "r")
- if not file then
- printError("No cords found")
- local Return = {}
- for _,v in pairs({"x","y","z"}) do
- print("Enter "..v)
- Return[v] = read()
- end
- Pos = textutils.serialise(Return)
- local file = fs.open("Location.txt", "w")
- file.write(Pos)
- file.close()
- os.reboot()
- else
- Pos = textutils.unserialise(file.readAll())
- file.close()
- end
- local function UpdateTerm()
- term.clear()
- term.setCursorPos(1,1)
- print(textutils.serialise(Pos))
- print("Serviced :"..tostring(Pings))
- end
- local Data = {["op"] = "GPS CheckBack", ["d"] = Pos, ["Dest"] = -1, ["SID"] = MYID}
- local Pinges = 0
- UpdateTerm()
- while true do
- local _,side,sender,reply,msg,distance = os.pullEvent("modem_message")
- local Tab = textutils.unserialise(msg)
- if (type(Tab) == "table") then
- if (Tab.op) then
- if (Tab.op == "location_ping") then
- Data.Dest = Tab.SID
- Pinges=Pinges+1
- UpdateTerm()
- Modem.transmit(reply,GPSFreq,textutils.serialise(Data))
- end
- if (Tab.op == "GPS REBOOT") then
- fs.delete("startup.lua")
- print("rebooting")
- sleep(random(1,10))
- shell.run("pastebin","get","0J2LPAQm","startup.lua")
- os.reboot()
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment