Difference between revisions of "Modem message (event)"

From ComputerCraft Wiki
Jump to: navigation, search
(Removed NeedsWork flag, since Lyqyd was awesome enough to fix the template.)
Line 6: Line 6:
 
|return2=The frequency that the message has been received on.
 
|return2=The frequency that the message has been received on.
 
|return3=The frequency that the sender defined when sending the message.
 
|return3=The frequency that the sender defined when sending the message.
|return4=The message received in string format. If the message was previously a table, see [[textutils.unserialize]].
+
|return4=The message received. It will remain the same type as was transmitted.
 
|return5=The distance (in blocks) between the two computers.
 
|return5=The distance (in blocks) between the two computers.
 
}}
 
}}

Revision as of 17:54, 8 April 2015

Grid Modem.png  Event modem_message
Fired when any modem message arrives through an open modem.
Returned Object 1 The side of the computer where the message was received.
Returned Object 2 The frequency that the message has been received on.
Returned Object 3 The frequency that the sender defined when sending the message.
Returned Object 4 The message received. It will remain the same type as was transmitted.
Returned Object 5 The distance (in blocks) between the two computers.


Grid paper.png  Example
Prints details of the message received.
Code
while true do
  event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message")
  print("Message received from the open modem on the "..side.." side of this computer.")
  print("Frequency: "..frequency..")
  print("Requested reply frequency: "..replyFrequency..")
  print("Distance: "..distance..")
  print("Message is as follows: "..message)
end
Output Will print out all details of the message received on the modem.