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

Is it possible to send commands via rednet to activate programs on other computers?

Started by christian-kapre, 04 October 2012 - 08:20 AM
christian-kapre #1
Posted 04 October 2012 - 10:20 AM
Is it possible for me to send a command from a computer to another computer that will in turn activate a certain program. If it is possible how is it done?
Doyle3694 #2
Posted 04 October 2012 - 10:30 AM
go look at rednet api on the wiki. wiki ftw
jag #3
Posted 04 October 2012 - 10:49 AM
rednet.open("top") -- set to wherever you got the modem
local id, message, distance = 0, "", 0
id, message, distance = rednet.receive()
shell.run(message)
rednet.close()
MatazaNz #4
Posted 04 October 2012 - 11:27 AM
Assuming you already know how to send a message, you can set up a turtle or computer that awaits a message. If the message matches what you have coded, the turtle will perform it's command, if not, it will continue waiting.
Mtdj2 #5
Posted 04 October 2012 - 02:04 PM
rednet.open("top") -- set to wherever you got the modem
local id, message, distance = 0, "", 0
id, message, distance = rednet.receive()
shell.run(message)
rednet.close()
Correcting:
rednet.open("top") -- set to wherever you got the modem
id, message, distance = rednet.receive()
shell.run(message)
rednet.close()
Fatal_Exception #6
Posted 04 October 2012 - 02:31 PM
Why change the locals into globals?
jag #7
Posted 04 October 2012 - 02:37 PM
Correcting:
rednet.open("top") -- set to wherever you got the modem
id, message, distance = rednet.receive()
shell.run(message)
rednet.close()
Well yeah, that's another way of doing it…
Flass Maximus #8
Posted 08 October 2012 - 11:12 AM
Could Someone Please elaborate on this? read the rather short wiki on rednet, tried all the examples from this page on an ingame lua console… Mine Didn't seem to work as intended.
seeing as im a "of no experience" in this field, i might be missing something blatantly obvious to those with more experience.
Zoinky #9
Posted 08 October 2012 - 11:22 AM

rednet.open("top") -- Turns on the modem. (Change "top" to whatever side you have it on)
id, message, distance = rednet.receive() -- Tells the computer to wait for messages. (rednet.receive() returns the id of computer as well as distance)
shell.run(message) -- Runs a program with the same name. (Eg. You typing "hello" into the terminal.)
rednet.close() -- Turns off the modem.

Not the best teacher… Lol. The "rednet.receive()" line might be a bit harder to understand. I was trying to explain it in a simple way :S Didn't want it to get too long.