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

Redstone Activated monitor

Started by Thomas9666, 23 May 2012 - 11:19 PM
Thomas9666 #1
Posted 24 May 2012 - 01:19 AM
I know I need a rednet network type thing for a monitor at a distance, but how do I code it so when a computer receives a redstone signal it turns on and runs the startup program?
MysticT #2
Posted 24 May 2012 - 02:24 AM
You can't make the computer turn on with a redstone signal, but you can make a program that waits for the signal and then starts the program.
ComputerCraftFan11 #3
Posted 24 May 2012 - 03:29 AM
You can't make the computer turn on with a redstone signal, but you can make a program that waits for the signal and then starts the program.

You can, put this in startup:

repeat
sleep(0)
os.reboot()
until rs.getOutput("side")
Lyqyd #4
Posted 24 May 2012 - 06:42 AM
That is, frankly, a terrible solution. Far better to simply wait in a program for the redstone pulse or to use a separate, hidden computer touching the first. When the second computer would receive the redstone pulse, it would turn on the first computer.
Luanub #5
Posted 24 May 2012 - 07:36 AM
I have to agree, the constant reboots are going to take their toll. Having one computer use the other as a peripherall is probably the cleanest way to go about doing something like this. You could use a turtle as well, send a signal to the turtle, its moves to the computer you want on and it turns it on for you(might not be to practicle depending on how far away the computer is since they move rather slow).
Cloudy #6
Posted 24 May 2012 - 11:03 AM
Rather than using another computer the best way is to put this in a startup file:


repeat
  sleep(0.5)
until rs.getInput("side")

shell.run("yourprogram", "and" "any", "arguments")
Lyqyd #7
Posted 24 May 2012 - 03:17 PM
Or just


while true do
    e, p1 = os.pullEvent("redstone")
    if redstone.getInput("side") then break end
end

Which will actually pause execution and wait for a redstone event to happen before it checks the redstone input.
Cloudy #8
Posted 24 May 2012 - 05:32 PM
Or just replace my sleep(0.5) with os.pullEvent("redstone") - but both bits of code have the same effect.
MysticT #9
Posted 24 May 2012 - 08:25 PM
Actually, it would be better like:

while not rs.getInput("side") do
  os.pullEvent("redstone")
end
since it would also check for input at startup. So if you have the input already on, it would work this way, and wouldn't wait for a redstone change to check again.
PixelToast #10
Posted 25 May 2012 - 04:27 AM
useful for mah monitor that turnes on once someone enters a room