Jump to content




Dynamic Message Receiving


  • You cannot reply to this topic
2 replies to this topic

#1 cdel

  • Banned
  • 496 posts
  • LocationMelbourne, Australia

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.

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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.

#3 cdel

  • Banned
  • 496 posts
  • LocationMelbourne, Australia

Posted 17 December 2014 - 12:51 PM

okay, thanks a bunch :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users