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

Pull multiple modem events in particular period

Started by mlugg, 05 June 2016 - 08:54 AM
mlugg #1
Posted 05 June 2016 - 10:54 AM
Hi,
Firstly sorry if I leave out some information or something, this is my first post.
I am working on designing a system to connect computers to a computer running a separate server OS. These servers send out messages over wireless modems to be picked up, and the user chooses which server (if any) to connect to. I want to make a function which will get all 'modem_message' events in a specified time period, and bundle them into a two-dimensional table with the frequency, reply-frequency, and message. How could I go about doing this?
Thanks in advance,
-Matthew
Lupus590 #2
Posted 05 June 2016 - 02:32 PM

start a timer and save its ID to a variable
while true do
  pull event
  if event is modem message then process
  elseif event is timer event
	if timer ID is the timer which was started above then
	  break loop

I can expand this if you need more help
Edited on 05 June 2016 - 12:33 PM
mlugg #3
Posted 05 June 2016 - 02:35 PM
 start a timer and save its ID to a variable while true do pull event if event is modem message then process elseif event is timer event if timer ID is the timer which was started above then break loop 
I can expand this if you need more help
I see, that makes sense. Thanks :)/>