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

Rednet help

Started by Abstract, 25 October 2012 - 04:03 PM
Abstract #1
Posted 25 October 2012 - 06:03 PM
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
ChunLing #2
Posted 25 October 2012 - 06:11 PM
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 #3
Posted 25 October 2012 - 06:13 PM
thanks, that worked