From ComputerCraft
Jump to: navigation, search
Occurs every time a wireless message has been received by a wrapped (wireless) modem that had the message's channel open.
  • name : string The side or network name of the wrapped Modem that received the message
  • channel : number The channel the message has been send on
  • channel : number The desired reply channel the sender specified
  • message : any The message's content
  • distance? : number The distance from the sender to the receiver, in meters/blocks. This will not be set if the modems are in different dimensions.
Part of CC:Tweaked
ExampleExampleReceiving modem messages
Wraps a connected modem peripheral, opens channel 123 and listens for incoming messages.
local modem = peripheral.find("modem")

while true do
  local event, peripheral_name, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  print("Received a message on channel", channel, "at", distance, "blocks away.")
  print("The message: ", message)
Triggered by the rednet coroutine and is created from the modem_message event. For most use cases, rednet.receive is usually easier to use.
  • id : number The supposed ID of the sender.
  • msg : any The message.
  • protocol? : string The specified protocol. Prior to ComputerCraft 1.6, was the distance between sender and reciever.
Part of CC:Tweaked
ExampleExamplePrint messages
Prints messages received through rednet. Requires that there is a modem open for rednet to use.
while true do
  local event, senderId, message, protocol = os.pullEvent("rednet_message")
  print("Computer", senderId, "sent a message", message, "with the", protocol, "protocol!")