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

[Question] Rednet Messages Not Being Picked Up

Started by jonster, 11 March 2012 - 10:40 PM
jonster #1
Posted 11 March 2012 - 11:40 PM
I'm working on a project for my server, and it involves rednet quite a bit. It's important that I can handle the "rednet_message" event as a part of the code, but I've run test code (seperate code just for testing events) and it doesn't seem to work:

[attachment=79:2012-03-11_23.30.31.png]

As you can see in the image, I have one computer attached to another via bundled cable.

One computer has this code…

rednet.open("back")
while true do
id, mes = rednet.receive(10)
print(id)
print(mes)
end

… and the other this:


rednet.open("back")
rednet.broadcast("hello world")

It's very simple, but for some reason nothing shows up on the receiving computer when I run the programs, although strangley sometimes the text on the screen does move up, as if some empty lines are being added. Either way it's big problem for me, so any ideas would be much appriciated, thanks.
Hawk777 #2
Posted 11 March 2012 - 11:44 PM
I assume you’re running the receiver first, otherwise the message will be dropped. I don’t see anything obviously wrong with this code. Have you tested whether just interfacing with bundled cable works properly (using the redstone API)? There are sometimes load-order issues; for bundled cable (including RedNet over bundled cable) to work right, ComputerCraft has to load after RedPower. Also, you might try replacing the bundled cable link with a pair of wireless modems (even if just for testing); these are more reliable, though they are limited to 64 metres range normally (and 16 metres during thunderstorms) compared to bundled cable’s 255 metre range.
Luanub #3
Posted 11 March 2012 - 11:58 PM
You can also use events to make it easier and so that the computer listening doesn't timeout before it gets the message by doing something like


rednet.open("back")
while true do
local event, id, mes = os.pullEvent("rednet_message")
print(id)
print(mes)
end
jonster #4
Posted 12 March 2012 - 09:28 PM
I assume you’re running the receiver first, otherwise the message will be dropped. I don’t see anything obviously wrong with this code. Have you tested whether just interfacing with bundled cable works properly (using the redstone API)? There are sometimes load-order issues; for bundled cable (including RedNet over bundled cable) to work right, ComputerCraft has to load after RedPower. Also, you might try replacing the bundled cable link with a pair of wireless modems (even if just for testing); these are more reliable, though they are limited to 64 metres range normally (and 16 metres during thunderstorms) compared to bundled cable’s 255 metre range.

ComputerCraft was definitley installed after RedPower, and I've been able to power specific colours in the bundled cable in previous tests. I'm still running 1.21 at the moment, so unfortunatley I can't try that yet, but I'll probably update soon so thanks for the advice.

You can also use events to make it easier and so that the computer listening doesn't timeout before it gets the message by doing something like
 rednet.open("back") while true do local event, id, mes = os.pullEvent("rednet_message") print(id) print(mes) end 

This was a step down from doing that, I was playing around with events, and I found this never showed up while other events worked fine. I did notice however that redstone events (not rednet) would never show any parameters. In fact, I only ever saw the first parameter for any event, although there was scope for 5. I haven't really thought much of it since I don't understand exactly what each event does yet (hence testing).