Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- V = settings.get("Version")
- local w,h = term.getSize()
- -- print centered on x axis
- function printCentered(y,s)
- local x = math.floor((w - string.len(s)) /2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(s)
- end
- --Draw menu function
- local mOption = 1
- local function drawMenu()
- term.clear()
- printCentered(1,"Lapis OS " .. V )
- term.setCursorPos(w-11,1)
- if mOption == 1 then
- term.write("Command Line")
- elseif mOption == 2 then
- term.write("Programs")
- elseif mOption == 3 then
- term.write("Shutdown")
- else
- end
- end
- --GUI
- local function drawFrontend()
- term.clear()
- printCentered(math.floor(h/2) - 3, "")
- printCentered(math.floor(h/2) - 2, "Start Menu")
- printCentered(math.floor(h/2) - 1, "")
- printCentered(math.floor(h/2) + 0, ((mOption == 1 and "[ Command Line ]") or " Command Line " ))
- printCentered(math.floor(h/2) + 1, ((mOption == 2 and "[ Programs ]") or " Programs " ))
- printCentered(math.floor(h/2) + 2, ((mOption == 3 and "[ Shutdown ]") or " Shutdown " ))
- end
- --Display
- drawMenu()
- drawFrontend()
- while true do
- local event, key = os.pullEvent()
- if event == "key" then
- if key == 265 or key == 87 then
- if mOption > 1 then
- mOption = mOption - 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 264 or key == 83 then
- if mOption < 3 then
- mOption = mOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 257 then
- break
- end
- end
- end
- if mOption == 1 then
- shell.run("/os/command")
- elseif mOption == 2 then
- shell.run("/os/programMenu")
- elseif mOption == 3 then
- os.shutdown()
- else
- end
Add Comment
Please, Sign In to add comment