Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CLIENT:::::::
- local compid
- local alv3
- local function Startup()
- term.clear()
- term.setCursorPos (1,1)
- rednet.open("right")
- print (" this Computer's id: ", os.getComputerID())
- print (" Set receiving computer's id:")
- print (" +--------------------------+ ")
- print (" | ")
- print (" +--------------------------+ ")
- print ()
- print (" message:")
- print (" +--------------------------+ ")
- print (" | ")
- print (" +--------------------------+ ")
- term.setCursorPos(5,4)
- repeat
- compid = tonumber(read())
- until compid
- term.setCursorPos(5,4)
- print ("id saved")
- term.setCursorPos(5,9)
- alv3 = read()
- term.setCursorPos(5,9)
- print ("message saved")
- sleep(0.5)
- Sender()
- Receive()
- end
- function Sender()
- term.clear()
- term.setCursorPos (1,1)
- print ("sending message in: ")
- print ("3")
- sleep(1)
- print ("2")
- sleep(1)
- print ("1")
- sleep(1)
- rednet.send(compid, alv3)
- sleep(1)
- print ("message sent")
- sleep(1)
- end
- function Receive()
- term.clear()
- term.setCursorPos (1,1)
- print (" this Computer's id: ", os.getComputerID())
- print (" waiting for message:")
- print (" +--------------------------+ ")
- print (" | ")
- print (" +--------------------------+ ")
- print ()
- print (" Terminal:")
- print (" +--------------------------+ ")
- print (" | ")
- print (" +--------------------------+ ")
- while true do
- rednet.open("right")
- senderID, message = rednet.receive()
- term.setCursorPos (5,4)
- print (message)
- sleep(0.5)
- term.setCursorPos (5,9)
- print (senderID)
- local event = os.pullEvent("key")
- rednet.close("right")
- Startup()
- break
- end
- end
- Startup()
- SERVER :::::::
- local compid
- local function Startup()
- term.clear()
- term.setCursorPos (1,1)
- print (" this Computer's id: ", os.getComputerID())
- print (" Set this Computer's label:")
- print (" +--------------------------+ ")
- print (" | ")
- print (" +--------------------------+ ")
- print ()
- print (" Set The Computer Terminal's ID")
- print (" +--------------------------+ ")
- print (" | ")
- print (" +--------------------------+ ")
- term.setCursorPos(5,4)
- local IgnLabel = read()
- os.setComputerLabel(IgnLabel)
- term.setCursorPos(5,4)
- print ("Label successful")
- term.setCursorPos(5,9)
- repeat
- compid = tonumber(read())
- until compid
- term.setCursorPos(5,9)
- print ("ID saved")
- sleep(2)
- print ("storing message")
- WriteFile()
- sleep(1)
- print ("sending stored messages")
- SendFile()
- print ("message sent!")
- sleep(5)
- Startup()
- end
- function WriteFile()
- rednet.open("right")
- id, message = rednet.receive()
- if id == compid then
- rednet.close()
- local h = fs.open("messages", "a")
- h:write(message)
- h:close()
- else
- print ("failed to write")
- sleep(5)
- end
- end
- function SendFile()
- local SendIt = fs.open("messages", "r")
- local shipment = SendIt.readAll()
- SendIt.close()
- rednet.open("right")
- rednet.send(compid, shipment)
- rednet.close("right")
- end
- Startup()
Advertisement
Add Comment
Please, Sign In to add comment