Advertisement
yeeeeeeeeeeeee

test

Mar 20th, 2025
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. local menuOptions = { "Open Drawing", "Open Programming", "Show Time", "Shutdown", "Uninstall OS" }
  2. local selectedIndex = 1
  3.  
  4. local function drawMenu()
  5.     term.clear()
  6.     term.setCursorPos(1, 1)
  7.     print("===== Yeeet OS =====")
  8.     print("Use Arrow Keys to Navigate and Enter to Select")
  9.  
  10.     for i, option in ipairs(menuOptions) do
  11.         if i == selectedIndex then
  12.             print("-> " .. option)
  13.         else
  14.             print("   " .. option)
  15.         end
  16.     end
  17. end
  18.  
  19. local function homeScreen()
  20.     while true do
  21.         drawMenu()
  22.         local event, key = os.pullEvent("key")
  23.  
  24.         if key == keys.up then
  25.             selectedIndex = selectedIndex - 1
  26.             if selectedIndex < 1 then
  27.                 selectedIndex = #menuOptions
  28.             end
  29.         elseif key == keys.down then
  30.             selectedIndex = selectedIndex + 1
  31.             if selectedIndex > #menuOptions then
  32.                 selectedIndex = 1
  33.             end
  34.         elseif key == keys.enter then
  35.             if menuOptions[selectedIndex] == "Open Drawing" then
  36.                 shell.run("draw.lua")
  37.             elseif menuOptions[selectedIndex] == "Open Programming" then
  38.                 shell.run("programming.lua")
  39.             elseif menuOptions[selectedIndex] == "Show Time" then
  40.                 term.clear()
  41.                 term.setCursorPos(1, 1)
  42.                 print("Current time: " .. textutils.formatTime(os.time(), true))
  43.                 print("\nPress any key to return.")
  44.                 os.pullEvent("key")
  45.             elseif menuOptions[selectedIndex] == "Shutdown" then
  46.                 os.shutdown()
  47.             elseif menuOptions[selectedIndex] == "Uninstall OS" then
  48.                 shell.run("uninstall.lua")
  49.             end
  50.         end
  51.     end
  52. end
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement