Advertisement
DOGGYWOOF

Doggy OS V2 BIOS System

Jan 23rd, 2025 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.06 KB | None | 0 0
  1. local w, h = term.getSize()
  2.  
  3. -- Function to center text horizontally
  4. local function centerText(y, text)
  5.     local x = math.floor((w - #text) / 2)
  6.     term.setCursorPos(x, y)
  7.     term.write(text)
  8. end
  9.  
  10. -- Function to draw the spinner animation
  11. local function drawSpinner(x, y, duration)
  12.     local spinnerFrames = {
  13.         "[    ]",
  14.         "[=   ]",
  15.         "[==  ]",
  16.         "[=== ]",
  17.         "[====]",
  18.         "[ ===]",
  19.         "[  ==]",
  20.         "[   =]",
  21.         "[    ]",
  22.         "[   =]",
  23.         "[  ==]",
  24.         "[ ===]",
  25.         "[====]",
  26.         "[=== ]",
  27.         "[==  ]",
  28.         "[=   ]"
  29.     }
  30.     local delay = 0.1
  31.     local frameCount = #spinnerFrames
  32.  
  33.     local spinnerX = x
  34.     local spinnerY = y
  35.  
  36.     local spinnerIndex = 1
  37.     local startTime = os.clock()
  38.     while os.clock() - startTime < duration do
  39.         term.setCursorPos(spinnerX, spinnerY)
  40.         term.write(spinnerFrames[spinnerIndex])
  41.  
  42.         spinnerIndex = spinnerIndex % frameCount + 1
  43.         os.sleep(delay)
  44.     end
  45. end
  46.  
  47. -- ASCII art dog image
  48. local dogImage = {
  49.     "     |\\_/|                  ",
  50.     "     | @ @   Doggy OS        ",
  51.     "     |   <>              _   ",
  52.     "     |  _/\\------____ ((| |))",
  53.     "     |               `--' |  ",
  54.     " _____|_       ___|   |___.' ",
  55.     "/_/_____/____/_______|       "
  56. }
  57.  
  58. -- Function to draw the ASCII art
  59. local function drawASCIIArt(y)
  60.     for i, line in ipairs(dogImage) do
  61.         centerText(y + i - 1, line)
  62.     end
  63. end
  64.  
  65. -- Function to show UEFI messages
  66. local function showUEFIMessage(message)
  67.     term.setBackgroundColor(colors.black)
  68.     term.clear()
  69.     term.setTextColor(colors.white)
  70.     local artHeight = #dogImage
  71.     local artY = math.floor((h - artHeight) / 2)
  72.     drawASCIIArt(artY)
  73.  
  74.     local spinnerX = math.floor(w / 2) - 3
  75.     local spinnerY = artY + #dogImage + 2
  76.     centerText(spinnerY, message)
  77. end
  78.  
  79. -- Placeholder function for boot options
  80. local function loadBootOptions()
  81.     term.setBackgroundColor(colors.black)
  82.     term.clear()
  83.     term.setTextColor(colors.white)
  84.     centerText(math.floor(h / 2), "Boot options loading...")
  85.     os.sleep(2.5)
  86. end
  87.  
  88. -- Placeholder function for boot animation
  89. local function loadBootAnimation()
  90.     term.setBackgroundColor(colors.black)
  91.     term.clear()
  92.  
  93.     term.setTextColor(colors.white)
  94.     local artHeight = #dogImage
  95.     local artY = math.floor((h - artHeight) / 2)
  96.     drawASCIIArt(artY)
  97.  
  98.     -- Calculate spinner position
  99.     local spinnerX = math.floor(w / 2) - 3
  100.     local spinnerY = artY + artHeight + 2
  101.  
  102.     -- Start spinner animation
  103.     drawSpinner(spinnerX, spinnerY, 9)  -- Spinner runs for 9 seconds
  104. end
  105.  
  106. -- Main function
  107. local function main()
  108.     showUEFIMessage("Hold DEL to show startup options")
  109.     local bootTimer = nil  -- Timer for detecting key hold
  110.     local keyPressTime = nil  -- Time when DEL key is first pressed
  111.     local keyHeldDown = false  -- Track if DEL is held down long enough
  112.     local idleTimer = os.startTimer(2)  -- Start 2-second idle timer to continue boot if no key is pressed
  113.  
  114.     while true do
  115.         local event, param = os.pullEvent()
  116.         if event == "key" then
  117.             -- Reset idle timer whenever a key is pressed
  118.             os.cancelTimer(idleTimer)
  119.             idleTimer = os.startTimer(2)  -- Start a new 2-second timer
  120.  
  121.             if param == keys.delete then
  122.                 if not keyPressTime then
  123.                     -- Mark the time when DEL is first pressed
  124.                     keyPressTime = os.clock()
  125.                     bootTimer = os.startTimer(3)  -- Start a 3-second timer when DEL is pressed
  126.                 end
  127.                 keyHeldDown = true
  128.                 -- Show message when DEL is held
  129.                 showUEFIMessage("Keep pressing DEL to enter the startup menu")
  130.             end
  131.         elseif event == "key_up" then
  132.             if param == keys.delete and keyHeldDown then
  133.                 local holdDuration = os.clock() - keyPressTime
  134.                 if holdDuration < 3 then
  135.                     -- If DEL is released before 3 seconds, continue boot process
  136.                     showUEFIMessage("DEL startup key released...")
  137.                     os.sleep(2.5)
  138.                     loadBootAnimation()
  139.                     return
  140.                 end
  141.                 keyPressTime = nil
  142.                 keyHeldDown = false
  143.             end
  144.         elseif event == "timer" then
  145.             if param == bootTimer then
  146.                 -- If DEL is held for 3 seconds, load boot options
  147.                 showUEFIMessage("Loading startup menu...")
  148.                 os.sleep(2.5)
  149.                 shell.run("disk/boot/boot-options")
  150.                 return
  151.             elseif param == idleTimer then
  152.                 -- If no key is pressed for 2 seconds, continue boot
  153.                 loadBootAnimation()
  154.                 return
  155.             end
  156.         end
  157.     end
  158. end
  159.  
  160. -- Run the main function
  161. main()
  162.  
  163. -- Clear screen after shutdown
  164. term.setBackgroundColor(colors.black)
  165. term.clear()
  166.  
  167. -- Load lockscreen
  168. shell.run("disk/os/lock.lua")
  169.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement