Built-in programs

listen
receives messages, remote
Type this at the prompt of a computer to copy it onto the medium:
> examples listen > edit listen
The program
-- Shows the messages sent by 'talk' from other computers.
-- The messages "on" and "off" also switch the top output:
-- a remote control for a door, a lamp, a machine...
print("Listening, I am #" .. net.id())
while true do
local m = net.receive() -- waits for a message
if m.channel == "chat" then
print("#" .. m.sender .. " (" .. m.via .. "): " .. tostring(m.data))
if m.data == "on" then rs.set("top", true) end
if m.data == "off" then rs.set("top", false) end
end
end