Tutorial/Simple Chat System

This tutorial covers some basics of Rednet  like how to send and receive messages.

For this tutorial you need 2 computers with a Wireless Modem for each of them. Place the modems at the back.

Now, we'll jump straight into coding one of the computers.

Create a file named "Chat" function clear -- This function will clear and reset the screen term.clear term.setCursorPos(1, 1) end clear rednet.open("back") -- Open the modem to start sending and receiving messages print("1. Send message") print("2. Wait for message") print("3. Exit program") while true do event, key = os.pullEvent("char") -- Wait until a key is pressed if key == "1" then -- If button pressed is 1 then... clear write("Message: ") text = read write("ID to send to: ") id = read id = tonumber(id) rednet.send(id, text) print("Message sent") sleep(1) shell.run("Chat") elseif key == "2" then -- If button pressed is 2 then... clear print("Waiting for message") print("Press enter to abort") while true do   event, param1, param2 = os.pullEvent if event == "rednet_message" then print("ID "..param1..": "..text) return elseif event == "char" and param1 == "enter" then print("Aborted") return end end end end And there we have it