Advertisement
karelvysinka

Modem Server 2022

Feb 5th, 2022 (edited)
1,374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. local version =
  2. 3
  3. -- Program pro >vysilani< zprav pres modem
  4. -- Pri zmene programu je treba na radku "2" zmenit verzi, aby se program automaticky aktualizoval
  5. -- "local code" je treba zmenit dle potreby
  6. -- Server:
  7. -- pastebin get NNbbTX6n startup
  8. -- Client:
  9. -- pastebin get yKvCXrCg startup
  10.  
  11. local code = "NNbbTX6n"
  12.  
  13. --check version
  14. term.clear()
  15. term.setCursorPos(1,1)
  16. print("Program loading...")
  17. print("Current version: "..version)
  18. local updateSite= http.get("http://pastebin.com/raw.php?i="..code)
  19. updateSite.readLine()
  20. local newVersion = updateSite.readLine()
  21. if tonumber(newVersion) > version then
  22.         print("Update required. Updating now...")
  23.         local updateSite = http.get("http://pastebin.com/raw.php?i="..code)
  24.         local siteFile = updateSite.readAll()
  25.         local writeFile = fs.open(shell.getRunningProgram(),"w")
  26.         writeFile.write(siteFile)
  27.         writeFile.close()
  28.         print("The program will now restart your computer.")
  29.         sleep(1)
  30.         os.reboot()
  31. end
  32.  
  33. function start()
  34.     while true do
  35.  
  36.        
  37.  
  38.         print ("Program bezi...")
  39.         local modem = peripheral.wrap("right") -- Wraps the modem on the right side.
  40.  
  41.         print("Zadej prikaz: ")
  42.         local input = read()
  43.         print("Odesilam prikaz:")
  44.         print(input)
  45.         print("..pres modem...")
  46.         rednet.broadcast(input)
  47.         print("Prikaz odeslan...")
  48.  
  49.  
  50.         modem.transmit(16384, 1, input)
  51.         --peripheral.call("right", "transmit", 16384, 1, "This will also work!")
  52.  
  53.  
  54.         rednet.open("right")
  55.         print ("Oteviram modem right.")
  56.        
  57.     end
  58. end
  59.  
  60.  
  61. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement