Create: Computing AgesBrass Docs
Built-in programs

listen

receives messages, remote

Runs on Mini+ Minicomputer and newer · 12 lines
Type this at the prompt of a computer to copy it onto the medium:
Terminal
> examples listen
> edit listen

The program

listen
-- 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