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

[solved] Rednet Help.

Started by GamingTom, 18 October 2013 - 12:22 PM
GamingTom #1
Posted 18 October 2013 - 02:22 PM
Hi, I have recently been learning how to use RedNet and I can use it correctly I believe. However, when I try to send a signal from a computer to a turtle to toggle a redstone signal, it doesn't work how I want. At the moment, if I send the signal, the turtle turns the redstone on, but not off after sending it again. However, if I tell the turtle to do it through a program without RedNet, it works perfectly. Here is my code:
Startup:
http://pastebin.com/xm3bpB94

rednet.open("right")
a,b,c = rednet.receive()
if b == "test" then
  shell.run("test")
  print("Running test!")
end
Test:
http://pastebin.com/fs0pgLkz

if rs.getInput("back",true) then
  rs.setOutput("back",false)
else
  rs.setOutput("back",true)
end

I know I don't particularly need to put "test" into it's own program, but I have tried to do it implemented into "startup". Any help in this matter would be greatly appreciated. Many thanks, Tom.
Lyqyd #2
Posted 19 October 2013 - 09:04 PM
Split into new topic.
Bomb Bloke #3
Posted 19 October 2013 - 10:07 PM
As it stands, your startup script accepts one signal, then finishes as it's got nothing left to do. You want it to repeat, yes?

rednet.open("right")
while true do
   a,b,c = rednet.receive()
   if b == "test" then
      shell.run("test")
      print("Running test!")
   end
end
GamingTom #4
Posted 20 October 2013 - 10:33 AM
Damn, I knew it would be something as simple as that, I'm pretty sure I tried it before as well. Anyway, thanks for the help, I've got it working now :)/>