Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("delete startup")
- shell.run("pastebin get nbXu8ZJu startup")
- os.pullEvent = os.pullEventRaw
- local w,h = term.getSize()
- 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
- local function drawMenu()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Cat OS 0.2.1 ALPHA ")
- term.setCursorPos(1,2)
- shell.run("id")
- term.setCursorPos(w-11,1)
- if nOption == 1 then
- term.write("Command")
- elseif nOption == 2 then
- term.write("Files")
- elseif nOption == 3 then
- term.write("Shutdown")
- elseif nOption == 4 then
- term.write("Uninstall")
- else
- end
- end
- --GUI
- term.clear()
- local function drawFrontend()
- printCentered( math.floor(h/2) - 3, "")
- printCentered( math.floor(h/2) - 2, "Cat OS Main 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 "[ Files ]") or "Files" )
- printCentered( math.floor(h/2) + 2, ((nOption == 3) and "[ Shutdown ]") or "Shutdown" )
- printCentered( math.floor(h/2) + 3, ((nOption == 4) and "[ Uninstall ]") or "Uninstall" )
- printCentered( math.floor(h/2) + 4, "")
- end
- --Display
- drawMenu()
- drawFrontend()
- while true do
- local 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 == 31 or key == 208 then
- if nOption < 4 then
- nOption = nOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 28 then
- --End should not be here!!
- break
- end --End should be here!!
- end
- end
- term.clear()
- --Conditions
- if nOption == 1 then
- shell.run(".os/command")
- elseif nOption == 2 then
- shell.run(".os/files")
- elseif nOption == 3 then
- os.shutdown()
- elseif nOption == 4 then
- shell.run("delete .os")
- shell.run("delete startup")
- shell.run("delete .recover")
- shell.run("delete .safemode")
- shell.run("delete .update")
- os.reboot()
- else
- print("Error this is not supposed to happen error code 001")
- end
Advertisement
Add Comment
Please, Sign In to add comment