Advertisement
mouse03f

MolnServer

Mar 4th, 2022 (edited)
1,663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. --MolnServer
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. rednet.open("right")
  5. while true do
  6.     local id, msg = rednet.receive()
  7.  
  8.     if msg == "ctlg" then
  9.         print("I started the grab")
  10.         local int = 1
  11.         while fs.list("")[int] ~= nil do
  12.             rednet.broadcast(fs.list("")[int])
  13.             int = int + 1
  14.         end
  15.         rednet.broadcast("Done!")
  16.         local id, name = rednet.receive()
  17.         print("Someone is grabbing "..name)
  18.         local file = fs.open(name, "r")
  19.         local text = file.readAll("")
  20.         file.close()
  21.         rednet.broadcast(name.."_copy")
  22.         sleep(0.1)
  23.         rednet.broadcast(text)
  24.         print("Succesful grab")
  25.    
  26.  
  27.     elseif msg == "svths"
  28.     then
  29.         local id, name = rednet.receive()
  30.         local id, text = rednet.receive()
  31.         local file = fs.open(name, "w")
  32.         file.write(text)
  33.         file.close()
  34.         print("I just received a new file called: ") print(name)
  35.     else
  36.         print("I got a msg: "..msg)
  37.     end
  38.  
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement