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

Need Help with far-controlled computers with rednet

Started by TheCursed_Donkey, 18 April 2012 - 08:21 AM
TheCursed_Donkey #1
Posted 18 April 2012 - 10:21 AM
HELLO! Im DonkeyzFTW an im a quite noob at computercraft… I need help with the rednet to controll my computer from another computer, if someone could help me with that :)/>/>
Luanub #2
Posted 18 April 2012 - 11:39 AM
First off read this so you kind of understand rednet http://www.computercraft.info/forums2/index.php?/topic/244-13-how-to-use-modems-rednet/

Next, using the rednet commands you will want to send a message to another computer and have that computer setup to where when it receives that message if performs a task.

Small example to turn a redstone signal on remotely.

Sending Computer:

rednet.open("side")
rednet.send(id, "redstoneOn")

Receiving Computer:

rednet.open("side")
id, msg = rednet.receive()
if msg == "redstoneOn" then
rs.setOutput("side", true)
end

Give it a shot, play around with it some and let us know when/if you run into problems with your code.
TheCursed_Donkey #3
Posted 18 April 2012 - 11:46 AM
Thank U :)/>/>
but dident work, i wrote:
39, msg = rednet.receive()
if msg == "OpenDoor" then
shell.run("open")
its the id number i think…
Luanub #4
Posted 18 April 2012 - 12:30 PM
Yeah you want to leave that id as just id.

id, msg = rednet.receive() –the var id in this command captures the first portion of the rednet message which is the senders id. So if you send a message from computer 1 saying "hello" and did the rednet.receive() on computer 2, id would == 1 and msg would == "hello".

rednet.send(id , "message") the id this command needs to be set to the computers id that you are sending the message to. so rednet.send(2, "hello")
Wolvan #5
Posted 18 April 2012 - 05:00 PM
id is a variable and you don't have to set it. Rednet will set it for you and it is the ID of the sending computer. You could write Peter or any other name instead of ID
TheCursed_Donkey #6
Posted 18 April 2012 - 06:13 PM
IT WORKED! THANKS TO U ALL!