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 tgtc = term.getTextColor
- local lightgrey = colors.lightGray
- local white = colors.white
- local black = colors.black
- local w, h = tgs()
- -- Centered Print function
- function centerPrint(y, s, d)
- local x = math.floor((w - string.len(s)) / 2)
- tscp(x, y)
- tcl()
- if d then
- tstc(lightgrey)
- else
- tstc(white)
- end
- 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("Send file")
- elseif nOption == 2 then
- tw("Get file")
- elseif nOption == 3 then
- tw("Back")
- else
- end
- end
- -- GUI
- tc()
- local function drawFrontend()
- centerPrint(math.floor(h / 2) - 3, "", true)
- centerPrint(math.floor(h / 2) - 2, "Programs", false)
- centerPrint(math.floor(h / 2) - 1, "", true)
- centerPrint(math.floor(h / 2) + 0, (nOption == 1 and "[ Send File ]" or "Send File"), false)
- centerPrint(math.floor(h / 2) + 1, (nOption == 2 and "[ Get File ]" or "Get File"), false)
- centerPrint(math.floor(h / 2) + 2, (nOption == 3 and "[ Back ]" or " Back "), false)
- end
- -- Display
- drawMenu()
- drawFrontend()
- local cw = 1
- local clg = 256
- 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 < 3 then
- nOption = nOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 257 then
- if tgtc() == cw then
- break
- end
- end
- end
- tc()
- -- Conditions
- if nOption == 1 then
- shell.run("os/.sfsecCheck")
- elseif nOption == 2 then
- shell.run("ios/.getfile")
- else
- shell.run(".menu")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement