Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- remote Movie controll
- by BigSHinyToys
- ]]--
- local function openDevice(sType)
- for i,v in pairs(rs.getSides()) do
- if peripheral.isPresent(v) and peripheral.getType(v) == sType then
- return peripheral.wrap(v),v
- end
- end
- end
- local _notused,monSide = openDevice("monitor")
- local _notused,wifiSide = openDevice("modem")
- if not monSide then
- error("No monitor Connected")
- end
- if wifiSide then
- rednet.open(wifiSide)
- else
- error("No wifi modem")
- end
- term.redirect(peripheral.wrap(monSide))
- local function newMovie()
- return coroutine.create(function() os.run({},"/rom/programs/secret/alongtimeago") end)
- end
- local movie = newMovie()
- local keepPlaying = false
- local lastEvent
- while true do
- local event = {os.pullEventRaw()}
- if event[1] == "rednet_message" then
- if event[3] == "play" then
- keepPlaying = true
- event = lastEvent or {}
- elseif event[3] == "pause" then
- keepPlaying = false
- elseif event[3] == "newFilm" then
- movie = newMovie()
- keepPlaying = false
- term.clear()
- elseif event[3] == "clear" then
- term.clear()
- elseif event[3] == "pingMovie" then
- rednet.send(event[2],"IamMovie")
- end
- elseif event[1] == "timer" then
- lastEvent = event
- elseif event[1] == "terminate" then
- term.clear()
- term.restore()
- error()
- end
- if keepPlaying then
- coroutine.resume(movie,unpack(event))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement