Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- remote cincima control
- by BigShinyToys
- ]]--
- local page = 0
- local movies = {}
- 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,sSide = openDevice("modem")
- if sSide then
- rednet.open(sSide)
- else
- error("No WIFI modem atatched")
- end
- local function clear()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- end
- local function ping()
- rednet.broadcast("pingMovie")
- movies = {}
- local timeOut = os.startTimer(2)
- while true do
- local event = {os.pullEvent()}
- if event[1] == "rednet_message" then
- if event[3] == "IamMovie" then
- table.insert(movies,event[2])
- end
- elseif event[1] == "timer" and event[2] == timeOut then
- return
- end
- end
- if #movies > 1 then
- page = 1
- else
- page = 0
- end
- end
- local function printC(posX,posY,textCol,backCol,text)
- term.setCursorPos(posX,posY)
- term.setTextColor(colors[textCol] or textCol)
- term.setBackgroundColor(colors[backCol] or backCol)
- term.write(text)
- end
- local tList = {{itm = "* play",mes = "play"},
- {itm = "* pause",mes = "pause"},
- {itm = "* Reset Film",mes = "newFilm"},
- {itm = "* clear",mes = "clear"},
- {itm = "* play all"},
- {itm = "* Reset All"}
- }
- clear()
- ping()
- while true do
- printC(1,1,"blue","lightBlue"," < > "..page.." of "..#movies)
- printC(1,2,"blue","lightBlue","* Ping")
- for i = 1,#tList do
- printC(1,i+2,"green","lime",tList[i].itm)
- end
- local event = {os.pullEvent()}
- if event[1] == "mouse_click" then
- if event[2] == 1 then
- if event[4] == 1 then
- if event[3] <= 3 then
- page = page + 1
- elseif event[3] > 3 and event[3] < 6 then
- page = page - 1
- end
- if #movies > 1 then
- if page < 1 then
- page = #movies
- elseif page > #movies then
- page = 0
- end
- elseif #movies == 1 then
- page = 1
- else
- page = 0
- end
- elseif event[4] == 2 then
- if event[3] < 6 then
- ping()
- end
- elseif tList[event[4]-2] then
- if tList[event[4]-2].mes then
- if movies[i] then
- rednet.send(movies[page],tList[event[4]-2].mes)
- end
- else
- if tList[event[4]-2].itm == "* play all" then
- for i = 1,#movies do
- rednet.send(movies[i],"play")
- end
- elseif tList[event[4]-2].itm == "* Reset All" then
- for i = 1,#movies do
- rednet.send(movies[i],"newFilm")
- end
- end
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment