This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Is it possible to send commands via rednet to activate programs on other computers?
Started by christian-kapre, 04 October 2012 - 08:20 AMPosted 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?
Posted 04 October 2012 - 10:30 AM
go look at rednet api on the wiki. wiki ftw
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()
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.
Posted 04 October 2012 - 02:04 PM
Correcting: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()
rednet.open("top") -- set to wherever you got the modem
id, message, distance = rednet.receive()
shell.run(message)
rednet.close()
Posted 04 October 2012 - 02:31 PM
Why change the locals into globals?
Posted 04 October 2012 - 02:37 PM
Well yeah, that's another way of doing it…Correcting:rednet.open("top") -- set to wherever you got the modem id, message, distance = rednet.receive() shell.run(message) rednet.close()
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.
seeing as im a "of no experience" in this field, i might be missing something blatantly obvious to those with more experience.
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.