From 4d8862c78ed3dcca15246d4e89b2f6f6a2934492 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Sun, 14 Nov 2021 01:57:47 -0500 Subject: [PATCH] Optimize peripheral calls in rednet.run (#954) --- src/main/resources/data/computercraft/lua/rom/apis/rednet.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua b/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua index db40ebeac..83f4bb6ad 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua @@ -403,10 +403,11 @@ function run() if sEvent == "modem_message" then -- Got a modem message, process it and add it to the rednet event queue local sModem, nChannel, nReplyChannel, tMessage = p1, p2, p3, p4 - if isOpen(sModem) and (nChannel == id_as_channel() or nChannel == CHANNEL_BROADCAST) then + if nChannel == id_as_channel() or nChannel == CHANNEL_BROADCAST then if type(tMessage) == "table" and type(tMessage.nMessageID) == "number" and tMessage.nMessageID == tMessage.nMessageID and not tReceivedMessages[tMessage.nMessageID] and ((tMessage.nRecipient and tMessage.nRecipient == os.getComputerID()) or nChannel == CHANNEL_BROADCAST) + and isOpen(sModem) then tReceivedMessages[tMessage.nMessageID] = os.clock() + 9.5 if not nClearTimer then nClearTimer = os.startTimer(10) end