Advertisement
mouse03f

MolnKlient

Mar 4th, 2022 (edited)
1,739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. --MolnKlient
  2. rednet.open("right")
  3. while(true) do
  4. local msg = io.read()
  5.  
  6. if msg == "send" then
  7.     print("please enter the name of the file you'd like to send:")
  8.     local file = io.read()
  9.     local file = fs.open(file, "r")
  10.     if file then
  11.         local text = file.readAll()
  12.         file.close()
  13.  
  14.         print("Give the file a name for the reciever")
  15.         local name = io.read()
  16.         rednet.broadcast("svths")
  17.         sleep(0.1)
  18.         rednet.broadcast(name)
  19.         sleep(0.1)
  20.         rednet.broadcast(text)
  21.         print("The file was transferred succesfully =)")
  22.     end
  23.  
  24. elseif  msg == "grab" then
  25.     rednet.broadcast("ctlg")
  26.     term.clear()
  27.     term.setCursorPos(1,1)
  28.     loop = true
  29.     while loop do
  30.         local id, msg = rednet.receive(5)
  31.         if msg == "Done!" then
  32.             loop = false
  33.         end
  34.         print(msg)
  35.     end
  36.     print("")
  37.     print("please enter the name of the file you'd like to grab:")
  38.     msg = io.read()
  39.     rednet.broadcast(msg)
  40.     local id, name = rednet.receive()
  41.     local id, text = rednet.receive()
  42.     local file = fs.open(name, "w")
  43.     file.write(text)
  44.     file.close()
  45.     print("The file has arrived on your main directory!")
  46.  
  47. else
  48. term.clear()
  49. term.setCursorPos(1,1)
  50.     print("The current server commands are send and grab")
  51. end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement