Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Stops Termination ability
- os.pullEvent = os.pullEventRaw
- shell.run("cd /")
- 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
- 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()
- tstc(colors.yellow)
- tscp(1,1)
- tw("CookieOS 1.0.0")
- tstc(colors.white)
- tscp(w - 11, 1)
- if nOption == 1 then
- tw("Confirm")
- elseif nOption == 2 then
- tw("Back")
- else
- end
- end
- -- GUI
- tc()
- local function drawFrontend()
- centerPrint(math.floor(h / 2) - 3, "")
- centerPrint(math.floor(h / 2) - 2, "Are you sure you want to uninstall?")
- centerPrint(math.floor(h / 2) - 1, "")
- centerPrint(math.floor(h / 2) - 0, (nOption == 1 and "[ Confirm ]" or " Confirm "))
- centerPrint(math.floor(h / 2) + 1, (nOption == 2 and "[ Back ]" or " Back "))
- 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("uninstall")
- else
- shell.run(".menu")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement