Here is my code so far (This is old code, please look further below for updated code):
Spoiler
function clear()
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.white)
end
function sendMessage()
clear()
write("Enter computer ID of receiver: ")
local receiver = tonumber(read())
print("Enter text: ")
local text = read()
clear()
write("Sending message...")
rednet.send(receiver, text, true)
print("Sent")
end
function viewMessage()
clear()
local senderID, text, distance = rednet.receive()
term.setCursorColor(colors.red)
write("Text: ")
term.setCursorColor(colors.white)
print(text)
term.setCursorColor(colors.green)
print("Sender info:")
term.setCursorColor(colors.red)
write("Sender ID: ")
term.setCursorColor(colors.white)
print(senderID)
term.setCursorColor(colors.red)
write("Distance from sender: ")
term.setCursorColor(colors.white)
print(distance)
sleep(10)
end
rednet.open("top")
name = os.getComputerLabel()
id = os.computerID()
clear()
print("Available tasks: ")
term.setTextColor(colors.red)
print("send")
term.setTextColor(colors.white)
write("Please enter a task: ")
task = read()
if task == "send" then
sendMessage()
else
clear()
print("Please enter a valid task.")
sleep(1)
end