←  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)

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

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.
Quote

Abstract's Photo Abstract 25 Oct 2012

thanks, that worked
Quote