Advertisement
pepeknamornik

CC - odeslani souboru

Feb 6th, 2020
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. local f=fs.open("/C/system/RAM/user","r")
  2. user=f.readLine()
  3. f.close()
  4. local f=fs.open("/LANconfig","r")
  5. server=f.readLine()
  6. f.close()
  7. idPC = os.getComputerID()
  8.  
  9. local modem = peripheral.wrap('top')
  10.  
  11. function odeslat()
  12.  
  13. modem.transmit(tonumber(adresat),1,soubor)
  14. print("odeslan nazev")
  15. modem.transmit(tonumber(adresat),2,obsah)
  16. print("odeslan obsah")
  17. modem.transmit(tonumber(adresat),3,idPC)
  18. print("odeslano ID")
  19. modem.transmit(tonumber(adresat),4,user)
  20. print("odeslan uzivatel")
  21. end
  22.  
  23. function cist()
  24. local data = fs.open(soubor, "r")
  25.     obsah = data.readAll()
  26.     data.close()
  27.    
  28.     odeslat()
  29. end
  30.  
  31. function start()
  32. term.clear()
  33. term.setCursorPos(1,1)
  34. write "soubor: "
  35. soubor = read()
  36. write "adresat [ID]: "
  37. adresat = read()
  38.     if adresat == nil then
  39.       print("musi byt cislo")
  40.       sleep(1)
  41.       start()
  42.     end
  43.  
  44.     if fs.exists(soubor) then
  45.     cist()
  46.     elseif fs.exists(soubor..".lua") then
  47.     soubor = soubor..".lua"
  48.     print ("soubor zmenen na: "..soubor)
  49.     cist()
  50.     else
  51.     write("Error")
  52.     sleep(1)
  53.     start()
  54.     end
  55. end
  56.  
  57. start ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement