Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --put these all in folder 'os' (mkdir os)
- --make this as .menu
- local w,h = term.getSize()
- function clearColor()
- setBackgroundColor(colors.black)
- end
- function printCentered (y,s)
- local x = math.floor((w- string.len(s)) / 2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(s)
- end
- local nOption = 1
- mon.write("Penguin OS 1.1 Running...")
- local function drawMenu()
- term.clear()
- setCursorPos(1,1)
- term.write("Penguin OS 1.1")
- setCursorPos(1,2)
- term.write("New Features: GUI Updates; Programs option runs an error screen")
- setCursorPos(1,3)
- term.write("because Programs function not yet finished{}")
- setCursorPos(1,4)
- term.write("Report any bugs to Penguinboy887")
- term.setCursorPos(w-11, 1)
- if nOption == 1 then
- term.write("Go to Command Prompt")
- elseif nOption == 2 then
- term.write("List Executable Programs")
- elseif nOption == 3 then
- term.write("Shut the Computer off")
- elseif nOption == 4 then
- term.write("Uninstall")
- else
- end
- local function drawFrontend()
- printCentered(math.floor(h/2) - 3, "----")
- printCentered(math.floor(h/2) - 2, "Menu")
- printCentered(math.floor(h/2) - 1, "----")
- printCentered(math.floor(h/2) - 0, ((nOption == 1) and "--{Command}--", or "|Command|")
- printCentered(math.floor(h/2) + 1, ((nOption == 2) and "--{Programs}--", or "|Programs|")
- printCentered(math.floor(h/2) + 2, ((nOption == 3) and "--{Shutdown}--", or "|Shutdown|")
- printCentered(math.floor(h/2) + 3, ((nOption == 4) and "--{Uninstall}--", or "|Uninstall|")
- end
- setBackgroundColor(colors.green)
- drawMenu()
- drawFrontend()
- while true do
- e,p = os.pullEvent()
- if e == "key" then
- local key = p
- if key == 17 or key == 200 then
- if nOption > 1 then
- nOption = nOption - 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 28 or key == 208 then
- if nOption < 4 then
- nOption = nOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif key = 28 then
- break
- end
- end
- end
- term.clear()
- if nOption == 1 then
- shell.run("os/.command")
- elseif nOption == 2 then
- shell.run("os/.programs")
- elseif nOption == 3 then
- os.shutdown()
- else
- shell.run("os/.uninstall")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement