Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,h = term.getSize()
- --Center Text
- function printCentered (y,s)
- local x = math.floor((w - string.len(s)) /2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(s)
- end
- --Drawmenu
- local nOption = 1
- local function drawMenu()
- term.setBackgroundColor(colors.cyan)
- term.clear()
- term.setCursorPos(1,1)
- local logo = paintutils.loadImage("os/.logo")
- paintutils.drawImage(logo, 1, 1)
- term.setBackgroundColor(colors.cyan)
- term.setCursorPos(w-11,1)
- if nOption == 1 then
- term.write("Play Disc")
- elseif nOption == 2 then
- term.write("Stop Disc")
- elseif nOption == 3 then
- term.write("Eject Disc")
- elseif nOption == 4 then
- term.write("Exit")
- else
- end
- end
- --GUI
- term.clear()
- local function drawFrontend()
- printCentered(math.floor(h/2) -3, "")
- printCentered(math.floor(h/2) -2, "START")
- printCentered(math.floor(h/2) -1, "")
- printCentered(math.floor(h/2) + 0, (nOption == 1 and "[ Play Disc ]") or "Play Disc")
- printCentered(math.floor(h/2) + 1, (nOption == 2 and "[ Stop Disc ]") or "Stop Disc")
- printCentered(math.floor(h/2) + 2, (nOption == 3 and "[ Eject Disc ]") or "Eject Disc")
- printCentered(math.floor(h/2) + 3, (nOption == 4 and "[ Exit ]") or "Exit")
- end
- --Display
- drawMenu()
- drawFrontend()
- while true do
- local e,p = os.pullEvent()
- if e == "key" then
- local key = p
- if key == keys.up or key == 200 then
- if nOption > 1 then
- nOption = nOption -1
- drawMenu()
- drawFrontend()
- end
- elseif key == keys.down or key == 208 then
- if nOption < 5 then
- nOption = nOption +1
- drawMenu()
- drawFrontend()
- end
- elseif key == keys.enter then
- break
- end
- end
- end
- term.clear()
- --Conditions
- if nOption == 1 then
- a = disk.hasAudio("left")
- b = disk.hasAudio("right")
- c = disk.hasAudio("top")
- d = disk.hasAudio("bottom")
- if a == true then
- disk.playAudio("left")
- elseif b == true then
- disk.playAudio("right")
- elseif c == true then
- disk.playAudio("top")
- elseif d == true then
- disk.playAudio("bottom")
- end
- shell.run("Music")
- elseif nOption == 2 then
- a = disk.hasAudio("left")
- b = disk.hasAudio("right")
- c = disk.hasAudio("top")
- d = disk.hasAudio("bottom")
- if a == true then
- disk.stopAudio("left")
- elseif b == true then
- disk.stopAudio("right")
- elseif c == true then
- disk.stopAudio("top")
- elseif d == true then
- disk.stopAduio("bottom")
- end
- shell.run("Music")
- elseif nOption == 3 then
- else
- shell.run("os/.functions")
- end
Advertisement
Add Comment
Please, Sign In to add comment