Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Stops Termination ability
- os.pullEvent = os.pullEventRaw
- local tscp = term.setCursorPos -- set cursor pos
- local tcl = term.clearLine -- clear line
- local tw = term.write -- write
- local tc = term.clear -- clear
- local tgs = term.getSize -- get size
- local tstc = term.setTextColor
- shell.run("cd /")
- tstc(colors.white)
- local w, h = tgs()
- -- Centered Print function
- function centerPrint(y, s)
- local x = math.floor((w - string.len(s)) / 2)
- tscp(x, y)
- tcl()
- tw(s)
- end
- -- Draw Menu Function
- local nOption = 1
- local function drawMenu()
- tc()
- tscp(1, 1)
- tstc(colors.yellow)
- tw("CookieOS 1.0.0")
- tstc(colors.white)
- tscp(w - 11, 1)
- if nOption == 1 then
- tw("Command")
- elseif nOption == 2 then
- tw("Programs")
- elseif nOption == 3 then
- tw("Shutdown")
- elseif nOption == 4 then
- tw("Reboot")
- elseif nOption == 5 then
- tw("Uninstall")
- else
- end
- end
- -- GUI
- tc()
- local function drawFrontend()
- centerPrint(math.floor(h / 2) - 3, "")
- centerPrint(math.floor(h / 2) - 2, "Start Menu")
- centerPrint(math.floor(h / 2) - 1, "")
- centerPrint(math.floor(h / 2) - 0, (nOption == 1 and "[ Command ]" or " Command "))
- centerPrint(math.floor(h / 2) + 1, (nOption == 2 and "[ Programs ]" or "Programs" ))
- centerPrint(math.floor(h / 2) + 2, (nOption == 3 and "[ Shutdown ]" or "Shutdown" ))
- centerPrint(math.floor(h / 2) + 3, (nOption == 4 and "[ Reboot ]" or "Reboot " ))
- centerPrint(math.floor(h / 2) + 4, (nOption == 5 and "[ Uninstall ]" or "Uninstall"))
- end
- -- Display
- drawMenu()
- drawFrontend()
- while true do
- local evt, key = os.pullEvent("key")
- if key == 265 then -- Up
- if nOption > 1 then
- nOption = nOption - 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 264 then -- Down
- if nOption < 5 then
- nOption = nOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 257 then
- break
- end
- end
- tc()
- -- Conditions
- if nOption == 1 then
- shell.run("os/.secCheck")
- elseif nOption == 2 then
- shell.run("os/.programs")
- elseif nOption == 3 then
- os.shutdown()
- elseif nOption == 4 then
- os.reboot()
- else
- shell.run("os/.uninstall")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement