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

shutdown pc with redstone signal?

Started by mikesaa309, 25 December 2012 - 05:58 AM
mikesaa309 #1
Posted 25 December 2012 - 06:58 AM
hi everyone, so i'm making a cinema with the help of cc (obviously). I've made a code (with help of this forum, i'm useless at coding) which turns on a computer and plays the "along time ago" movie. At first this was supposed to work from startup but i found that it didn't recognize the redstone signal if the computer was off unless there is away. so i changed the code to run after you start a program up which for ease i just called the program test so you turn the computer on then type test then it waits for a redstone signal and when thats found it plays the movie.

While this works fine i want to change the code so that when i turn the lever off it will stop the movie (or terminate the program). The redstone circuit is set up as follows: there is a lever in a room which leads to a redstone lamp above which simulates a projector (i may adapt it so it flickers like a projector). Also from the same lever there is redstone leading to the computer positioned behind the monitor. So basically when i turn the projector (redstone lamp) on the movie begins playing but i also want it so that when i turn the project off the movie stops playing thus the screen goes blank.

Here is the original: code (before i tried to make it terminate the program without help):


while true do
os.pullEvent("redstone")
if rs.getInput("right") then – change side to the side you want to check
shell.run("monitor", "back", "secret/alongtimeago")
break
end
end

below is the code after i tried to go what im asking for help with by myself (but i'm useless at coding so it failed)


while true do
os.pullEvent("redstone")
if rs.getInput("right") then – change side to the side you want to check
shell.run("monitor", "back", "secret/alongtimeago") else
os.pullEvent("redstone")
if not rs.getInput("right") then
os.pullEvent(terminate)
break
end
end
Luanub #2
Posted 25 December 2012 - 07:36 AM
Instead of this "os.pullEvent(terminate)" do os.shutdown()
mikesaa309 #3
Posted 25 December 2012 - 07:55 AM
It still doesn't work. I also tried using an elseif statement but it still does nothing. Also if i shut the computer down then wouldn't that mean i'd have to go and manually turn it back on? As its hidden behind the monitor, i do have a underground tunnel type thing to access the computer but its a bit of a walk to keep going there and as i'm not very good with programming I don't know how to set up a wireless computer so i can control everything from one computer which i wanna do but havn't a clue how to do it. Maybe you or someone else could help? Using the code on my first post how would i wirelessly transmit that from one computer to the computer behind the monitor and still make the movie play on the monitor?