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

redstone input to play movie

Started by moxzot, 10 July 2012 - 02:41 AM
moxzot #1
Posted 10 July 2012 - 04:41 AM
i was wondering if anyone knew how to make it to when i put a rs signal in my console it starts a movie on a monitor and stops it when the rs signal goes away
1lann #2
Posted 10 July 2012 - 02:18 PM
hmmm, that's a bit tricky XD. But basically what you need to do is have a file to run the movie upon redstone input and another file to basically manage the variables from the "run the movie upon redstone input" file to the "movie" file, so then the movie can stop.
So the managing movie file would be like

local play = false
function set(bool)
  play = bool
end

function get(bool)
  play = bool
end
Then you will load it as an API in your "run the movie upon redstone input" file and the "movie" file.
Your "run the movie upon redstone input" file should be something like (In this example, the API will be named "movie")

os.loadAPI("movie")

function runMovie()
shell.run("movie file name here")
end

function main()
os.pullEvent("redstone")
movie.set(true)
parallel.waitForAny(runMovie, checkRedstone)
return
end

function checkRedstone()
os.pullEvent("redstone")
movie.set(false)
return
end

while true do
main()
end

And within the movie program, you would use an if statement to check whether movie.get() is true, if it's not, quit the movie program using return or break ect.

Please note I have not tested this