Advertisement
yeeeeeeeeeeeee

test 6

Mar 23rd, 2025
508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.49 KB | None | 0 0
  1. -- Yeeet OS Main Script (startup.lua)
  2.  
  3. -- Cat ASCII Art for Loading Screen
  4. local catArt = [[
  5.  /\_/\  
  6. ( o.o )
  7.  > ^ <
  8. ]]
  9.  
  10. -- Save Theme to File
  11. local function saveTheme(theme)
  12.     local file = fs.open("theme.txt", "w")
  13.     file.write(theme)
  14.     file.close()
  15. end
  16.  
  17. -- Load Theme from File
  18. local function loadTheme()
  19.     if fs.exists("theme.txt") then
  20.         local file = fs.open("theme.txt", "r")
  21.         local theme = file.readAll()
  22.         file.close()
  23.         return theme
  24.     else
  25.         return "light" -- Default to Light Mode
  26.     end
  27. end
  28.  
  29. -- Apply Theme
  30. local function applyTheme(theme)
  31.     if theme == "dark" then
  32.         term.setBackgroundColor(colors.black)
  33.         term.setTextColor(colors.white)
  34.     elseif theme == "light" then
  35.         term.setBackgroundColor(colors.white)
  36.         term.setTextColor(colors.black)
  37.     elseif theme == "superlight" then
  38.         term.setBackgroundColor(colors.white)
  39.         term.setTextColor(colors.lightGray)
  40.     end
  41.     term.clear()
  42. end
  43.  
  44. -- Loading Screen Function
  45. local function loadingScreen()
  46.     term.clear()
  47.     term.setCursorPos(1, 1)
  48.     print("===== Yeeet OS =====")
  49.     print("")
  50.  
  51.     -- Print cat art on both sides
  52.     local width, height = term.getSize()
  53.     for line in string.gmatch(catArt, "[^\n]+") do
  54.         term.setCursorPos(1, term.getCursorPos())
  55.         print(line)
  56.         term.setCursorPos(width - #line + 1, term.getCursorPos() - 1)
  57.         print(line)
  58.     end
  59.  
  60.     -- Print loading bar in the middle
  61.     term.setCursorPos(1, height)
  62.     print("Loading...")
  63.     for i = 1, 20 do
  64.         sleep(0.2) -- Simulate slow loading
  65.         write("=")
  66.     end
  67.     sleep(1)
  68.     term.clear()
  69. end
  70.  
  71. -- Home Screen Navigation
  72. local menuOptions = { "Open Drawing", "Open Programming", "Show Time", "Change Theme", "Shutdown", "Uninstall OS" }
  73. local selectedIndex = 1
  74.  
  75. local function drawMenu()
  76.     term.clear()
  77.     term.setCursorPos(1, 1)
  78.     print("===== Yeeet OS =====")
  79.     print("Use Arrow Keys to Navigate and Enter to Select")
  80.  
  81.     for i, option in ipairs(menuOptions) do
  82.         if i == selectedIndex then
  83.             print("-> " .. option)
  84.         else
  85.             print("   " .. option)
  86.         end
  87.     end
  88. end
  89.  
  90. local function changeTheme()
  91.     term.clear()
  92.     term.setCursorPos(1, 1)
  93.     print("Select a Theme:")
  94.     print("1. Dark Mode")
  95.     print("2. Light Mode")
  96.     print("3. Super Light Mode (Not Recommended)")
  97.     write("Enter your choice (1-3): ")
  98.     local choice = read()
  99.  
  100.     if choice == "1" then
  101.         saveTheme("dark")
  102.         applyTheme("dark")
  103.         print("Dark Mode activated!")
  104.     elseif choice == "2" then
  105.         saveTheme("light")
  106.         applyTheme("light")
  107.         print("Light Mode activated!")
  108.     elseif choice == "3" then
  109.         saveTheme("superlight")
  110.         applyTheme("superlight")
  111.         print("Super Light Mode activated! Good luck reading.")
  112.     else
  113.         print("Invalid choice. Returning to Home Screen.")
  114.     end
  115.  
  116.     sleep(2)
  117. end
  118.  
  119. -- Home Screen Function
  120. local function homeScreen()
  121.     while true do
  122.         drawMenu()
  123.         local event, key = os.pullEvent("key")
  124.  
  125.         if key == keys.up then
  126.             selectedIndex = selectedIndex - 1
  127.             if selectedIndex < 1 then
  128.                 selectedIndex = #menuOptions
  129.             end
  130.         elseif key == keys.down then
  131.             selectedIndex = selectedIndex + 1
  132.             if selectedIndex > #menuOptions then
  133.                 selectedIndex = 1
  134.             end
  135.         elseif key == keys.enter then
  136.             if menuOptions[selectedIndex] == "Open Drawing" then
  137.                 shell.run("draw.lua")
  138.             elseif menuOptions[selectedIndex] == "Open Programming" then
  139.                 shell.run("programming.lua")
  140.             elseif menuOptions[selectedIndex] == "Show Time" then
  141.                 term.clear()
  142.                 term.setCursorPos(1, 1)
  143.                 print("Current time: " .. textutils.formatTime(os.time(), true))
  144.                 print("\nPress any key to return.")
  145.                 os.pullEvent("key")
  146.             elseif menuOptions[selectedIndex] == "Change Theme" then
  147.                 changeTheme()
  148.             elseif menuOptions[selectedIndex] == "Shutdown" then
  149.                 os.shutdown()
  150.             elseif menuOptions[selectedIndex] == "Uninstall OS" then
  151.                 shell.run("uninstall.lua")
  152.             end
  153.         end
  154.     end
  155. end
  156.  
  157. -- Main Execution
  158. local theme = loadTheme()
  159. applyTheme(theme)
  160. loadingScreen()
  161. homeScreen()
  162.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement