Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function online()
- term.clear()
- term.setCursorPos(1,1)
- rednet.open("right")
- function receive()
- while(true) do
- local id, msg = rednet.receive()
- if msg == "ctlg" then
- local text = fs.list()
- rednet.broadcast(text)
- end
- if msg == "svths"
- then
- local id, name = rednet.receive()
- local id, text = rednet.receive()
- local file = fs.open(name, "w")
- file.write(text)
- file.close()
- print("you just received a new file called: ") print(name)
- else
- print(msg)
- end
- end
- end
- function send()
- while(true) do
- local msg = io.read()
- if msg == "send"
- then
- print("please enter the name of the file you'd like to send:")
- local file = io.read()
- local file = fs.open(file, "r")
- if file then
- local text = file.readAll()
- file.close()
- print("Give the file a name for the reciever")
- local name = io.read()
- rednet.broadcast("svths")
- sleep(0.1)
- rednet.broadcast(name)
- sleep(0.1)
- rednet.broadcast(text)
- print("The file was transferred succesfully =)")
- end
- if msg == "grab" then
- print("please enter the name of the file you'd like to send:")
- local file = io.read()
- local file = fs.open(file, "r")
- if file then
- local text = file.readAll()
- file.close()
- print("Give the file a name for the reciever")
- local name = io.read()
- rednet.broadcast("svths")
- sleep(0.1)
- rednet.broadcast(name)
- sleep(0.1)
- rednet.broadcast(text)
- print("The file was transferred succesfully =)")
- else
- print("File doesn't exist.")
- end
- else
- rednet.broadcast("RMS: "..msg)
- end
- end
- end
- parallel.waitForAll(receive,send)
- end
- online()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement