Jump to content




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


  • You cannot reply to this topic
2 replies to this topic

#1 mrpoopy345

  • Members
  • 148 posts
  • LocationMy Computer

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)

#2 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

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 by HPWebcamAble, 08 March 2015 - 06:14 PM.


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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.

View PostHPWebcamAble, on 08 March 2015 - 06:11 PM, said:

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.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users