←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft


Rednet help

Abstract's Photo Abstract 25 Oct 2012

Hi everybody

I've played around with rednet a little bit and wrote a little program, which doesn't work correctly.. Here is what it should do:
If it gets the command, it should extend a pisten and with another command it should retract it
Now here's the problem: It only extends and does not retract... here's the code of my receiver computer(id4)

while true do
id,message = rednet.receive()
if message == "on" then
rs.setOutput("back", true)
if message == "off" then
rs.setOutput("back", false)
what is wrong/missing there? I would be glad if someone could help me

ChunLing's Photo ChunLing 25 Oct 2012

You're not using os.pullEvent() for anything, but it still pulls events off the event queue and makes the event unavailable for rednet.receive(). So half of your events are being discarded without being used. Try sending "off" multiple times. Or just remove the os.pullEvent() call, you're not using it anyway.

Abstract's Photo Abstract 25 Oct 2012

thanks, that worked