Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Yeeet OS Main Script (startup.lua)
- -- Cat ASCII Art for Loading Screen
- local catArt = [[
- /\_/\
- ( o.o )
- > ^ <
- ]]
- -- Save Theme to File
- local function saveTheme(theme)
- local file = fs.open("theme.txt", "w")
- file.write(theme)
- file.close()
- end
- -- Load Theme from File
- local function loadTheme()
- if fs.exists("theme.txt") then
- local file = fs.open("theme.txt", "r")
- local theme = file.readAll()
- file.close()
- return theme
- else
- return "light" -- Default to Light Mode
- end
- end
- -- Apply Theme
- local function applyTheme(theme)
- if theme == "dark" then
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- elseif theme == "light" then
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- elseif theme == "superlight" then
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.lightGray)
- end
- term.clear()
- end
- -- Loading Screen Function
- local function loadingScreen()
- term.clear()
- term.setCursorPos(1, 1)
- print("===== Yeeet OS =====")
- print("")
- -- Print cat art on both sides
- local width, height = term.getSize()
- for line in string.gmatch(catArt, "[^\n]+") do
- term.setCursorPos(1, term.getCursorPos())
- print(line)
- term.setCursorPos(width - #line + 1, term.getCursorPos() - 1)
- print(line)
- end
- -- Print loading bar in the middle
- term.setCursorPos(1, height)
- print("Loading...")
- for i = 1, 20 do
- sleep(0.2) -- Simulate slow loading
- write("=")
- end
- sleep(1)
- term.clear()
- end
- -- Home Screen Navigation
- local menuOptions = { "Open Drawing", "Open Programming", "Show Time", "Change Theme", "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 changeTheme()
- term.clear()
- term.setCursorPos(1, 1)
- print("Select a Theme:")
- print("1. Dark Mode")
- print("2. Light Mode")
- print("3. Super Light Mode (Not Recommended)")
- write("Enter your choice (1-3): ")
- local choice = read()
- if choice == "1" then
- saveTheme("dark")
- applyTheme("dark")
- print("Dark Mode activated!")
- elseif choice == "2" then
- saveTheme("light")
- applyTheme("light")
- print("Light Mode activated!")
- elseif choice == "3" then
- saveTheme("superlight")
- applyTheme("superlight")
- print("Super Light Mode activated! Good luck reading.")
- else
- print("Invalid choice. Returning to Home Screen.")
- end
- sleep(2)
- end
- -- Home Screen Function
- 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] == "Change Theme" then
- changeTheme()
- elseif menuOptions[selectedIndex] == "Shutdown" then
- os.shutdown()
- elseif menuOptions[selectedIndex] == "Uninstall OS" then
- shell.run("uninstall.lua")
- end
- end
- end
- end
- -- Main Execution
- local theme = loadTheme()
- applyTheme(theme)
- loadingScreen()
- homeScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement