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

Rednet.send working, but rednet sending not working...

Started by mrpoopy345, 08 March 2015 - 03:11 PM
mrpoopy345 #1
Posted 08 March 2015 - 04:11 PM
I'm not sure why this is happening, but I am trying to rewrite rednet,send, and this is my (debugging) code:

function send( nRecipient, sMessage )
	for n,sSide in ipairs( rs.getSides() ) do
		if rednet.isOpen( sSide ) then
			peripheral.call( sSide, "transmit", nRecipient, os.getComputerID(), sMessage )
			return true
		end
	end
	error( "No open sides" )
end
send(1, "foo")
rednet.send(1, "bar")
And for some reason, even though my send function code is directly copied from computercrafts source, the send function doesn't get through (I know peripheral.call got executed, yet nothing shows up on the other side) but rednet.send works just fine. Does anyone know why and how to fix it? (My current theory is that the send() function isn't generating a rednet_message event, and therefore rednet.receive() ignores it, but I'm not sure how to fix that)
HPWebcamAble #2
Posted 08 March 2015 - 06:11 PM
Why do you need to rewrite the function when yours does basically the same thing?


Anyways, your problem is that rednet has its own protocol, so just sending a string won't trigger it.
The original function creates a table with several things, and that's what it looks for.
Edited on 08 March 2015 - 05:14 PM
Bomb Bloke #3
Posted 08 March 2015 - 10:48 PM
Make sure you read the source for rednet.run(). It explains how your modem_message events are supposed to magically turn into rednet_message events.

The original function creates a table with several things, and that's what it looks for.

… assuming you're on CC 1.6 or later.