Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- CineWare V1.0
- Author(s): Torje
- Required stuff:
- 8x3 monitor
- Disk drive x2
- Advanced computer x1
- Cinema [OPTIONAL BUT RECOMMENDED]
- --]]
- -- Variables
- local movie1 = "/disk/alongtimeago"
- local movie2 = "/movies/nyancat"
- local movie3 = "clear"
- -- Movie selection menu
- ocal menu_options = {
- [1] = {text="Star Wars IV: A New Hope", color=colors.red},
- [2] = {text="Nyan Cat the Movie", color=colors.blue},
- [3] = {text="Exit", color=colors.grey}
- }
- local termX, termY = term.getSize()
- local function menuDraw(selected)
- local yPos = termY/2 - #menu_options/2
- for index, data in pairs(menu_options) do
- menu_options[index].bounds = {
- x1 = termX/2 - (#data.text+4)/2,
- x2 = termX/2 + (#data.text+4)/2,
- y = yPos
- }
- term.setTextColor(data.color)
- term.setCursorPos(data.bounds.x1, data.bounds.y)
- local text =
- index==selected and "["..data.text.."]" or
- " "..data.text.." "
- term.write(text)
- yPos = yPos+1
- end
- end
- local function checkClick(x,y)
- for index, data in pairs(menu_options) do
- if x>= data.bounds.x1 and x<= data.bounds.x2 and y==data.bounds.y then
- return index
- end
- end
- return false
- end
- term.clear()
- local selector = 1
- while true do
- menuDraw(selector)
- local e = {os.pullEvent()}
- if e[1] == "key" then
- if e[2] == keys.down then
- selector = selector < #menu_options and selector+1 or 1
- elseif e[2] == keys.up then
- selector = selector > 1 and selector-1 or 3 or #menu_options
- elseif e[2] == keys.enter then
- break
- end
- elseif e[1] == "mouse_click" then
- local value = checkClick(e[3], e[4])
- if value then
- selector = value
- break
- end
- end
- end
- if selector == 1 then
- term.clear()
- term.setCursorPos(1,1)
- textutils.slowPrint("Starting movie...", 15)
- sleep(1)
- shell.run(movie1)
- end
- if selector == 2 then
- term.clear()
- term.setCursorPos(1,1)
- textutils.slowPrint("Starting movie...", 15)
- sleep(1)
- shell.run(movie2)
- end
- if selector == 3 then
- term.clear()
- term.setCursorPos(1,1)
- textutils.slowPrint("Starting movie...", 15)
- sleep(1)
- shell.run(movie3)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement