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

[Question] How can i rednet.send to get a rednet.send back ?

Started by Lakur545, 06 April 2012 - 07:07 PM
Lakur545 #1
Posted 06 April 2012 - 09:07 PM
The problem I am having is:
I rednet.send then go into receive(), and then it stops.
It was intended to get a rednet.send from another machine.
help would be appreciated

first pc
Spoiler

rednet.open("top")
rednet.send(3, "check")
while true do
a, b = rednet.receive()
if b == "on" then
print("on")
end
end
second pc
Spoiler

rednet.open("top")
while true do
e, p1 = rednet.receive()
a = rs.getOutput("left")
if p1 == "check" then
  if a == true then
  rednet.send(1, "on")
  elseif a == false then
  rednet.send(1, "off")
  end
end
end
ComputerCraftFan11 #2
Posted 06 April 2012 - 09:10 PM
The problem I am having is:
I rednet.send then go into receive(), and then it stops.
It was intended to get a rednet.send from another machine.
help would be appreciated

first pc
Spoiler

rednet.open("top")
rednet.send(3, "check")
while true do
a, b = rednet.receive()
if b == "on" then
print("on")
end
end
second pc
Spoiler

rednet.open("top")
while true do
e, p1 = rednet.receive()
a = rs.getOutput("left")
if p1 == "check" then
  if a == true then
  rednet.send(1, "on")
  elseif a == false then
  rednet.send(1, "off")
  end
end
end
Try to run the second program first then run the first one
Lakur545 #3
Posted 06 April 2012 - 09:24 PM
have tried that, doesn't work

*edit now my check on the 1. pc spits out either 28 or 32… ?
ComputerCraftFan11 #4
Posted 06 April 2012 - 09:28 PM
do you have a modem on top?
Lakur545 #5
Posted 06 April 2012 - 09:30 PM
on both pc's, yes
Lakur545 #6
Posted 06 April 2012 - 09:35 PM
I know this my be bothersome for you ComputerCraftFan11, but could you try and write the code as you would've done it ?
ComputerCraftFan11 #7
Posted 06 April 2012 - 09:52 PM
Program 1 would be like this:

rednet.open("top")
rednet.send(3, "check")
while true do
a, b = rednet.receive()
if b == "on" then
print("on")
elseif b == "off" then
print("off")
end
end

Program 2 would be like this:

rednet.open("top")
while true do
id, message = rednet.receive()
if message == "check" then
if rs.getInput("left") == true then
rednet.send(id, "on")
elseif rs.getInput("left") == false then
rednet.send(id, "off")
end
end
end


Found out problem:
you put rs.getOutput, i changed it to getInput, now try
Lakur545 #8
Posted 06 April 2012 - 10:01 PM
thxs that worked