I would like to add that you can also override the
rednet.send function
rednet.send = function(id, fakeID, msg)
for n,sSide in ipairs( rs.getSides() ) do
if isOpen( sSide ) then
peripheral.call( sSide, "transmit", id, fakeID, msg )
return
end
end
error( "No open sides" )
end
But the code by Mikk809 is easier and shorter.
Can you explain what "n,sSide in ipairs( rs.getSides() )" the ipairs* part means? Thank you.
Also if I put this in a resource pack under rednet and change the rednet send to this, would that work for a server? can I make it so that every message on a server get's sent to one or two main computers?(Given that they're all in range)
Hellkid98's function is looping through all sides of the computer, to check if there is a modem on one of the sides.. If so, then it calls the peripheral.call to activate the transmit function with the message and the ID.
But, if you're going to set previous code in a ressource pack, then you're not safe.. then anyone else on the server, can set their "fakeID" to 0 or whatever id you need, and then on that way spam / do something really bad on the main computer..
can I make it so that every message on a server get's sent to one or two main computers?(Given that they're all in range)
errm… Yes that is possible. you "just" need to input two messages to sent ( one for each id of the main computers ) , and then return true / false
example:
mainComputer1 = 0
mainComputer2 = 82
rednet.send = function(id, fakeID, msg)
for n,sSide in ipairs( rs.getSides() ) do
if isOpen( sSide ) then
peripheral.call( sSide, "transmit", id, fakeID, msg ) -- this is to the id.
peripheral.call( sSide, "transmit", mainComputer1, fakeID, msg ) -- this is to the mainComputer no. 1.
peripheral.call( sSide, "transmit", mainComputer2, fakeID, msg ) -- this is to the mainComputer no. 2.
return
end
end
error( "No open sides" )
end