Advertisement
yeeeeeeeeeeeee

Yeeet OS

Mar 20th, 2025
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.68 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. -- User Profile Storage
  11. local function saveProfile(username)
  12.     local profile = {
  13.         username = username,
  14.         preferences = { theme = "default" }
  15.     }
  16.     local file = fs.open("/user_profile.txt", "w")
  17.     file.write(textutils.serialize(profile))
  18.     file.close()
  19. end
  20.  
  21. local function loadProfile()
  22.     if fs.exists("/user_profile.txt") then
  23.         local file = fs.open("/user_profile.txt", "r")
  24.         local profile = textutils.unserialize(file.readAll())
  25.         file.close()
  26.         return profile
  27.     else
  28.         return nil
  29.     end
  30. end
  31.  
  32. -- Loading Screen
  33. local function loadingScreen()
  34.     term.clear()
  35.     term.setCursorPos(1, 1)
  36.     print("===== Yeeet OS =====")
  37.     print("")
  38.  
  39.     -- Print cat art on both sides
  40.     local width, height = term.getSize()
  41.     for line in string.gmatch(catArt, "[^\n]+") do
  42.         term.setCursorPos(1, term.getCursorPos())
  43.         print(line)
  44.         term.setCursorPos(width - #line + 1, term.getCursorPos() - 1)
  45.         print(line)
  46.     end
  47.  
  48.     -- Print loading bar
  49.     term.setCursorPos(1, height)
  50.     print("Loading...")
  51.     for i = 1, 20 do
  52.         sleep(0.2)
  53.         write("=")
  54.     end
  55.     sleep(1)
  56.     term.clear()
  57. end
  58.  
  59. -- Admin Copy OS Feature
  60. local function copyOS()
  61.     if not disk.isPresent("left") then
  62.         print("No disk detected. Please insert a writable disk into the left disk drive.")
  63.         return
  64.     end
  65.  
  66.     local diskPath = disk.getMountPath("left")
  67.     print("Copying OS to disk...")
  68.  
  69.     -- List of files to copy
  70.     local osFiles = { "startup.lua", "uninstall.lua", "draw.lua" }
  71.     for _, file in ipairs(osFiles) do
  72.         if fs.exists(file) then
  73.             fs.copy(file, diskPath .. "/" .. file)
  74.         end
  75.     end
  76.     print("OS copied successfully to the disk!")
  77. end
  78.  
  79. -- Admin Login Screen
  80. local function adminCommands()
  81.     while true do
  82.         print("Admin Commands: 'copy', 'exit'")
  83.         write("Admin Command: ")
  84.         local adminInput = read()
  85.  
  86.         if adminInput == "copy" then
  87.             copyOS()
  88.         elseif adminInput == "exit" then
  89.             break
  90.         else
  91.             print("Unknown admin command.")
  92.         end
  93.     end
  94. end
  95.  
  96. local function loginScreen()
  97.     print("Welcome to Yeeet OS!")
  98.     local profile = loadProfile()
  99.     if profile then
  100.         print("Welcome back, " .. profile.username .. "!")
  101.     else
  102.         write("New User. Enter a Username: ")
  103.         local username = read()
  104.         saveProfile(username)
  105.         print("Profile saved! Welcome, " .. username .. "!")
  106.     end
  107.  
  108.     print("Admin Login Required:")
  109.     write("Username: ")
  110.     local username = read()
  111.     write("Password: ")
  112.     local password = read("*") -- Masks the password input
  113.  
  114.     if username == "admin" and password == "Loveycat0!" then
  115.         print("Login successful!")
  116.         adminCommands()
  117.     else
  118.         print("Invalid username or password. Shutting down.")
  119.         sleep(2)
  120.         os.shutdown()
  121.     end
  122. end
  123.  
  124. -- Drawing Feature
  125. local function drawProgram()
  126.     shell.run("draw.lua")
  127. end
  128.  
  129. -- Programming Environment
  130. local function programmingEnvironment()
  131.     print("Programming Environment")
  132.     print("Commands: 'run <file>', 'save <file>', 'load <file>', 'exit'")
  133.     while true do
  134.         write("> ")
  135.         local input = read()
  136.         local command, arg = string.match(input, "^(%S+)%s*(.*)$")
  137.  
  138.         if command == "run" and arg then
  139.             if fs.exists(arg) then
  140.                 local success, err = pcall(function() shell.run(arg) end)
  141.                 if not success then
  142.                     print("Error: " .. err)
  143.                     local log = fs.open("/error_log.txt", "a")
  144.                     log.writeLine("Error while running " .. arg .. ": " .. err)
  145.                     log.close()
  146.                 end
  147.             else
  148.                 print("File not found.")
  149.             end
  150.         elseif command == "save" and arg then
  151.             write("Enter your code. Type 'end' to finish.")
  152.             local code = ""
  153.             while true do
  154.                 local line = read()
  155.                 if line == "end" then break end
  156.                 code = code .. line .. "\n"
  157.             end
  158.             local file = fs.open(arg, "w")
  159.             file.write(code)
  160.             file.close()
  161.             print("File saved as " .. arg)
  162.         elseif command == "load" and arg then
  163.             if fs.exists(arg) then
  164.                 local file = fs.open(arg, "r")
  165.                 print(file.readAll())
  166.                 file.close()
  167.             else
  168.                 print("File not found.")
  169.             end
  170.         elseif command == "exit" then
  171.             break
  172.         else
  173.             print("Invalid command.")
  174.         end
  175.     end
  176. end
  177.  
  178. -- Home Screen Navigation
  179. local menuOptions = { "Open Drawing", "Open Programming", "Show Time", "Shutdown", "Uninstall OS" }
  180. local selectedIndex = 1
  181.  
  182. local function drawMenu()
  183.     term.clear()
  184.     term.setCursorPos(1, 1)
  185.     print("===== Yeeet OS =====")
  186.     print("Use Arrow Keys to Navigate and Enter to Select")
  187.  
  188.     for i, option in ipairs(menuOptions) do
  189.         if i == selectedIndex then
  190.             print("-> " .. option)
  191.         else
  192.             print("   " .. option)
  193.         end
  194.     end
  195. end
  196.  
  197. local function homeScreen()
  198.     while true do
  199.         drawMenu()
  200.         local event, key = os.pullEvent("key")
  201.  
  202.         if key == keys.up then
  203.             selectedIndex = selectedIndex - 1
  204.             if selectedIndex < 1 then
  205.                 selectedIndex = #menuOptions
  206.             end
  207.         elseif key == keys.down then
  208.             selectedIndex = selectedIndex + 1
  209.             if selectedIndex > #menuOptions then
  210.                 selectedIndex = 1
  211.             end
  212.         elseif key == keys.enter then
  213.             if menuOptions[selectedIndex] == "Open Drawing" then
  214.                 drawProgram()
  215.             elseif menuOptions[selectedIndex] == "Open Programming" then
  216.                 programmingEnvironment()
  217.             elseif menuOptions[selectedIndex] == "Show Time" then
  218.                 term.clear()
  219.                 term.setCursorPos(1, 1)
  220.                 print("Current time: " .. textutils.formatTime(os.time(), true))
  221.                 print("\nPress any key to return.")
  222.                 os.pullEvent("key")
  223.             elseif menuOptions[selectedIndex] == "Shutdown" then
  224.                 os.shutdown()
  225.             elseif menuOptions[selectedIndex] == "Uninstall OS" then
  226.                 shell.run("uninstall.lua")
  227.             end
  228.         end
  229.     end
  230. end
  231.  
  232. -- Main Execution
  233. loadingScreen()
  234. loginScreen()
  235. homeScreen()
  236.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement