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

Execute remote program

Started by Wice, 13 September 2014 - 10:41 PM
Wice #1
Posted 14 September 2014 - 12:41 AM
Hello,

I'm connecting multiple computers and monitors through wired modems.

Assuming I have a computer_1 and computer_2, which are connected via compOne = peripheral.wrap("computer_1") etc. There are two things I can't figure out:

1) How to let computer_1 output a redstone signal from a specific side of computer_2 (in other words: I'm looking for a command that I can execute on computer_1 that will output a redstone signal at the back side of computer_2)

2) How can I get a list of methods of a remote device (like computer_2 or monitor_1) on computer_1?

Thanks in advance!


EDIT:
3) I'm trying to let computer_1 tell computer_2 to run the program /disk/folder/example (which is stored on computer_2's diskdrive)
Edited on 13 September 2014 - 11:29 PM
Lyqyd #2
Posted 14 September 2014 - 12:44 AM
1. You can't, directly. The second computer would need to be running a program specifically to take rednet messages and set redstone outputs based on those messages.

2. peripheral.getMethods(peripheral_name), for example:


local methods = peripheral.getMethods("computer_2")
Wice #3
Posted 14 September 2014 - 12:50 AM
1. You can't, directly. The second computer would need to be running a program specifically to take rednet messages and set redstone outputs based on those messages.

2. peripheral.getMethods(peripheral_name), for example:


local methods = peripheral.getMethods("computer_2")

I was afraid that would be the sollution. I remember doing something like that quite a while ago but I completely forgot how to do it :)/> Thanks for the answers though, I'll start trying to find out how to do remote programs again!
Wice #4
Posted 14 September 2014 - 01:19 AM
Hello,

I'm connecting multiple computers and monitors through wired modems.

Assuming I have a computer_1 and computer_2, which are connected via compOne = peripheral.wrap("computer_1") etc.

I'm trying to let computer_1 tell computer_2 to run the program /disk/folder/example (which is stored on computer_2's diskdrive)

I've done something similar in the past but I can't figure out how to do it anymore, can anybody help me out?

Thanks in advace!
Lyqyd #5
Posted 14 September 2014 - 01:23 AM
Threads merged. Please stick to one topic for a given problem, even as the problem evolves. Feel free to update the topic title by using the full editor on the first post.
Wice #6
Posted 14 September 2014 - 01:27 AM
Threads merged. Please stick to one topic for a given problem, even as the problem evolves. Feel free to update the topic title by using the full editor on the first post.

Alright, thanks for merging then!
Wice #7
Posted 14 September 2014 - 01:42 AM
Ok, I found my solution:

computer_1:


rednet.open("back")
rednet.broadcast("open","myProtocol")

computer_2:


function listen()
while true do
id, msg, distance = rednet.receive("myProtocol")

if msg == "open" then 
redstone.setOutput("back", false)
end

if msg == "close" then 
redstone.setOutput("back", true)
end

sleep(1)
end
end

rednet.open("bottom")
listen()