Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Menu System
- local WIDTH, HEIGHT = term.getSize()
- local menuItems = {
- {
- "OS Update",
- function()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Updating...")
- os.sleep(1)
- if fs.exists("startup") then
- shell.run("delete startup")
- end
- shell.run("pastebin get vpMfYK0v startup")
- os.reboot()
- end
- },
- {
- "Programs",
- function()
- term.clear()
- term.setCursorPos(1,1)
- term.write("No functionality yet!")
- os.sleep(1)
- return
- end
- },
- {
- "Install",
- function()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Soon to be way of installing ur fav programs")
- os.sleep(1)
- end
- },
- {
- "Quit",
- function()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Shutting down...")
- os.sleep(1)
- return true
- end
- }
- }
- function runSelection(option)
- return menuItems[option][2]()
- end
- function initScreen()
- term.clear()
- term.setCursorPos(1,1)
- --Check if installation is proper etc..
- end
- --Prints text in the center of a selected row
- function printCenter(h, msg)
- term.setCursorPos(math.floor((WIDTH-string.len(msg))/2), h)
- term.clearLine()
- term.write(msg)
- end
- function drawMenu(option)
- term.clear()
- for i, item in ipairs(menuItems) do
- if i == option then
- term.setTextColor(colors.lightBlue)
- printCenter(i+3, "["..item[1].."]")
- term.setTextColor(colors.white)
- else
- printCenter(i+3, item[1])
- end
- end
- end
- --TODO: Add a function for checking on updates (FOR NOW JUST GETS STARTUP)
- initScreen()
- local option = 1
- while true do
- drawMenu(option)
- local event, key = os.pullEvent("key")
- if key == keys.up then
- option = option - 1
- elseif key == keys.down then
- option = option + 1
- end
- --Bound check options
- if option > table.getn(menuItems) then
- option = option - 1
- elseif option == 0 then
- option = option + 1
- end
- drawMenu(option)
- if key == keys.enter then
- if runSelection(option) == true then
- term.clear()
- term.setCursorPos(1,1)
- break
- end
- end
- end
Add Comment
Please, Sign In to add comment