This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
cdel's profile picture

Dynamic Message Receiving

Started by cdel, 17 December 2014 - 11:39 AM
cdel #1
Posted 17 December 2014 - 12:39 PM
My receiving function is as follows:


local receive = function(timeout)
  modem.open(channel)
  local _, _, _, _, message, distance = os.pullEvent("modem_message")
  return message, distance
end

I am wanting to receive a dynamic amount of messages within the timeout duration, and then save the messages and distances that are returned into a table for later use.
Bomb Bloke #2
Posted 17 December 2014 - 12:49 PM
Assuming for now that you've already got some idea as to how you're going to set up your table:

Instead of specifically pulling "modem_message" events, pull all events, and then check to see which type they are - this will allow you to have the function return once a timer expires.
cdel #3
Posted 17 December 2014 - 12:51 PM
okay, thanks a bunch :)/>