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 )
- > ^ <
- ]]
- -- Profile Handling Functions
- local function saveProfile(username)
- local file = fs.open("profile.txt", "w")
- file.write(username)
- file.close()
- end
- local function loadProfile()
- if fs.exists("profile.txt") then
- local file = fs.open("profile.txt", "r")
- local username = file.readAll()
- file.close()
- return username
- else
- return nil
- end
- 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) -- Brief pause before proceeding
- term.clear()
- end
- -- First-Time Sign-In Screen
- local function firstSignIn()
- print("Welcome to Yeeet OS!")
- print("It seems like you're a new user.")
- write("Please enter your new username: ")
- local username = read()
- saveProfile(username) -- Save the new username
- print("Hello, " .. username .. "! Your profile has been created.")
- sleep(2)
- end
- -- Admin Login Function
- local function loginScreen()
- term.clear()
- print("Welcome back to Yeeet OS!")
- print("Admin Login Required:")
- write("Username: ")
- local username = read()
- write("Password: ")
- local password = read("*") -- Masks password input
- if username == "admin" and password == "Loveycat0!" then
- print("Login successful!")
- sleep(1)
- homeScreen() -- Navigate to home screen after successful login
- else
- print("Invalid username or password. Shutting down.")
- sleep(2)
- os.shutdown()
- end
- end
- -- Home Screen Navigation
- 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
- -- Home Screen Logic
- 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
- -- Main Execution Logic
- loadingScreen()
- local username = loadProfile()
- if not username then
- firstSignIn() -- Run the first-time sign-in screen if no profile exists
- end
- loginScreen()
Add Comment
Please, Sign In to add comment