Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version =
- 10
- -- Program pro >prijmani< zprav pres modem
- -- Pri zmene programu je treba na radku "2" zmenit verzi, aby se program automaticky aktualizoval
- -- "local code" je treba zmenit dle potreby
- -- Server:
- -- pastebin get NNbbTX6n startup
- -- Client:
- -- pastebin get yKvCXrCg startup
- local code = "yKvCXrCg"
- --kontrola verze
- term.clear()
- term.setCursorPos(1,1)
- print("Program loading...")
- print("Current version: "..version)
- local updateSite= http.get("http://pastebin.com/raw.php?i="..code)
- updateSite.readLine()
- local newVersion = updateSite.readLine()
- if tonumber(newVersion) > version then
- print("Update required. Updating now...")
- local updateSite = http.get("http://pastebin.com/raw.php?i="..code)
- local siteFile = updateSite.readAll()
- local writeFile = fs.open(shell.getRunningProgram(),"w")
- writeFile.write(siteFile)
- writeFile.close()
- print("The program will now restart your computer.")
- sleep(1)
- os.reboot()
- end
- print("Program OK...")
- function start()
- while true do
- local modem = peripheral.wrap("right")
- modem.open(16384) -- Otevri kanal a naslouchej na nem
- --print("Waiting message...")
- local event, modemSide, senderChannel,
- replyChannel, message, senderDistance = os.pullEvent("modem_message")
- --print("Prave jsem obdrzel zpravu na kanalu: "..senderChannel)
- --print("Mel bych na to odpovedet na kanalu: "..replyChannel)
- --print("Prijimajici modem je umisten na zarizeni: "..modemSide.." side")
- print(message)
- --print("Odesilatelem je: "..(senderDistance or "neznamy pocet").." bloku ode me.")
- end
- end
- function provedPrikaz(message)
- if message == "test" then
- print("Test")
- end
- if message == "reboot" then
- print("Rebootuji computer")
- os.reboot()
- end
- print("Konec provadeni prikazu")
- end
- start()
Add Comment
Please, Sign In to add comment