Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local menuOptions = { "Open Drawing", "Open Programming", "Show Time", "Shutdown", "Uninstall OS" }
- local selectedIndex = 1
- local function drawMenu()
- term.clear()
- term.setCursorPos(1, 1)
- print("===== Yeeet OS =====")
- print("Use Arrow Keys to Navigate and Enter to Select")
- for i, option in ipairs(menuOptions) do
- if i == selectedIndex then
- print("-> " .. option)
- else
- print(" " .. option)
- end
- end
- end
- local function homeScreen()
- while true do
- drawMenu()
- local event, key = os.pullEvent("key")
- if key == keys.up then
- selectedIndex = selectedIndex - 1
- if selectedIndex < 1 then
- selectedIndex = #menuOptions
- end
- elseif key == keys.down then
- selectedIndex = selectedIndex + 1
- if selectedIndex > #menuOptions then
- selectedIndex = 1
- end
- elseif key == keys.enter then
- if menuOptions[selectedIndex] == "Open Drawing" then
- shell.run("draw.lua")
- elseif menuOptions[selectedIndex] == "Open Programming" then
- shell.run("programming.lua")
- elseif menuOptions[selectedIndex] == "Show Time" then
- term.clear()
- term.setCursorPos(1, 1)
- print("Current time: " .. textutils.formatTime(os.time(), true))
- print("\nPress any key to return.")
- os.pullEvent("key")
- elseif menuOptions[selectedIndex] == "Shutdown" then
- os.shutdown()
- elseif menuOptions[selectedIndex] == "Uninstall OS" then
- shell.run("uninstall.lua")
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement