Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Get the username and channel
- write("Username: ")
- username = read()
- write("Channel: ")
- channel = read()
- term.clear()
- term.setCursorPos(1,1)
- -- Open any modems on the computer
- peripheral.find("modem", rednet.open)
- message = ""
- -- Creates a window in the terminal for the chat
- termX, termY = term.getSize()
- -- Recieves chat messages from other clients on the same channel
- function receiveChat()
- print()
- print(rednet.receive(channel))
- end
- -- Sends messages to other clients on the same channel
- function sendMsg()
- while true do
- write(">: ")
- message = read()
- if message == "exit[]" then
- os.reboot()
- end
- term.clearLine()
- rednet.broadcast(username..": '"..message.."', on ", channel)
- end
- end
- -- Runs the functions in parallel so you can recieve and send messages at the same time
- while true do
- parallel.waitForAny(receiveChat, sendMsg)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement