Posted 17 September 2014 - 12:05 AM
I have a program that displays a lot of information on a monitor. Most of this information is local, but I have a few things that are pulled from remote computers via modem. Everything works but I have a strong suspicion I am not doing things the best way and there is room for improvement. I also don't want to wait for modem events as I have timers built in elsewhere and I would like my monitor to be able to update every second. The snippet of code I am talking about is below:
So here you can see I am waiting for two modems to send to me. If my thinking is correct the whole script will pause until I receive two messages. It also looks somewhat unreliable to me as well.
Is there a better way to do what I am trying to achieve?
Thanks!
function getmodem()
local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
if replyChannel == 1 then
ScndPwr = message
end
if replyChannel == 2 then
fsChk = message
end
local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
if replyChannel == 1 then
ScndPwr = message
end
if replyChannel == 2 then
fsChk = message
end
end
So here you can see I am waiting for two modems to send to me. If my thinking is correct the whole script will pause until I receive two messages. It also looks somewhat unreliable to me as well.
Is there a better way to do what I am trying to achieve?
Thanks!