1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-22 21:23:21 +00:00
CC-Tweaked/doc/events/rednet_message.md
Jonathan Coates 8a203e7454
Re-license several more files under MPL-2.0
- Several files where @MCJack123 is the exclusive contributor. He has
   signed over all contributions to "any OSI-approved license". Thank
   you!

 - Various the file handle classes: Looking at these again, I don't
   think they contain any of the original code.
2023-03-28 10:28:59 +01:00

1.3 KiB

module: [kind=event] rednet_message see: modem_message For raw modem messages sent outside of Rednet. see: rednet.receive To wait for a Rednet message with an optional timeout and protocol filter.

The @{rednet_message} event is fired when a message is sent over Rednet.

This event is usually handled by @{rednet.receive}, but it can also be pulled manually.

@{rednet_message} events are sent by @{rednet.run} in the top-level coroutine in response to @{modem_message} events. A @{rednet_message} event is always preceded by a @{modem_message} event. They are generated inside CraftOS rather than being sent by the ComputerCraft machine.

Return Values

  1. @{string}: The event name.
  2. @{number}: The ID of the sending computer.
  3. @{any}: The message sent.
  4. @{string}|@{nil}: The protocol of the message, if provided.

Example

Prints a message when one is sent:

while true do
  local event, sender, message, protocol = os.pullEvent("rednet_message")
  if protocol ~= nil then
    print("Received message from " .. sender .. " with protocol " .. protocol .. " and message " .. tostring(message))
  else
    print("Received message from " .. sender .. " with message " .. tostring(message))
  end
end