1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-26 07:03:22 +00:00

rednet.send now returns if the message was send (#164)

This makes use of the "sent" variable, which would otherwise go unused. It also makes rednet.send compliant to the behaviour specified in the Wiki: http://www.computercraft.info/wiki/Rednet.send
This commit is contained in:
Luca S 2019-04-01 20:31:21 +02:00 committed by SquidDev
parent e4ef92ca2d
commit 390575ab4d

View File

@ -81,13 +81,13 @@ function send( nRecipient, message, sProtocol )
sProtocol = sProtocol,
}
local sent = false
if nRecipient == os.getComputerID() then
-- Loopback to ourselves
os.queueEvent( "rednet_message", nReplyChannel, message, sProtocol )
sent = true
else
-- Send on all open modems, to the target and to repeaters
local sent = false
for n,sModem in ipairs( peripheral.getNames() ) do
if isOpen( sModem ) then
peripheral.call( sModem, "transmit", nRecipient, nReplyChannel, tMessage );
@ -96,6 +96,8 @@ function send( nRecipient, message, sProtocol )
end
end
end
return sent
end
function broadcast( message, sProtocol )