15 posts
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?
1604 posts
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.
718 posts
Location
Hawaii
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")
8543 posts
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.
1111 posts
Location
Portland OR
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).
2447 posts
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")
8543 posts
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.
2447 posts
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.
1604 posts
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.
2217 posts
Location
3232235883
Posted 25 May 2012 - 04:27 AM
useful for mah monitor that turnes on once someone enters a room