Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- function printLeft (y,s)
- local x = math.floor((w - string.len(s)) / 2)
- term.setCursorPos(x - 18 , y)
- term.clearLine()
- term.write(s)
- end
- local nOption = 1
- local function drawMenu()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Atlantica OS v1.1")
- end
- term.clear()
- local function drawFrontend()
- printCentered(math.floor(h/2) - 3, "")
- printCentered(math.floor(h/2) - 2, "Desktop")
- printCentered(math.floor(h/2) - 1, "")
- printCentered(math.floor(h/2) + 0, ((nOption == 1) and "[ Command ]") or "Command" )
- printCentered(math.floor(h/2) + 1, "")
- printCentered(math.floor(h/2) + 2, ((nOption == 2) and "[ Programs ]") or "Programs" )
- printCentered(math.floor(h/2) + 3, "")
- printCentered(math.floor(h/2) + 4, ((nOption == 3) and "[ Shutdown ]") or "Shutdown" )
- end
- 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 < 3 then
- nOption = nOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 28 then
- break
- end
- end
- end
- term.clear()
- if nOption == 1 then
- shell.run(".command")
- elseif nOption == 2 then
- shell.run(".programs")
- else
- os.shutdown()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement