Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w, h = term.getSize()
- -- Function to center text horizontally
- local function centerText(y, text)
- local x = math.floor((w - #text) / 2)
- term.setCursorPos(x, y)
- term.write(text)
- end
- -- Function to draw the spinner animation
- local function drawSpinner(x, y, duration)
- local spinnerFrames = {
- "[ ]",
- "[= ]",
- "[== ]",
- "[=== ]",
- "[====]",
- "[ ===]",
- "[ ==]",
- "[ =]",
- "[ ]",
- "[ =]",
- "[ ==]",
- "[ ===]",
- "[====]",
- "[=== ]",
- "[== ]",
- "[= ]"
- }
- local delay = 0.1
- local frameCount = #spinnerFrames
- local spinnerX = x
- local spinnerY = y
- local spinnerIndex = 1
- local startTime = os.clock()
- while os.clock() - startTime < duration do
- term.setCursorPos(spinnerX, spinnerY)
- term.write(spinnerFrames[spinnerIndex])
- spinnerIndex = spinnerIndex % frameCount + 1
- os.sleep(delay)
- end
- end
- -- ASCII art dog image
- local dogImage = {
- " |\\_/| ",
- " | @ @ Doggy OS ",
- " | <> _ ",
- " | _/\\------____ ((| |))",
- " | `--' | ",
- " _____|_ ___| |___.' ",
- "/_/_____/____/_______| "
- }
- -- Function to draw the ASCII art
- local function drawASCIIArt(y)
- for i, line in ipairs(dogImage) do
- centerText(y + i - 1, line)
- end
- end
- -- Function to show UEFI messages
- local function showUEFIMessage(message)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- local artHeight = #dogImage
- local artY = math.floor((h - artHeight) / 2)
- drawASCIIArt(artY)
- local spinnerX = math.floor(w / 2) - 3
- local spinnerY = artY + #dogImage + 2
- centerText(spinnerY, message)
- end
- -- Placeholder function for boot options
- local function loadBootOptions()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- centerText(math.floor(h / 2), "Boot options loading...")
- os.sleep(2.5)
- end
- -- Placeholder function for boot animation
- local function loadBootAnimation()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- local artHeight = #dogImage
- local artY = math.floor((h - artHeight) / 2)
- drawASCIIArt(artY)
- -- Calculate spinner position
- local spinnerX = math.floor(w / 2) - 3
- local spinnerY = artY + artHeight + 2
- -- Start spinner animation
- drawSpinner(spinnerX, spinnerY, 9) -- Spinner runs for 9 seconds
- end
- -- Main function
- local function main()
- showUEFIMessage("Hold DEL to show startup options")
- local bootTimer = nil -- Timer for detecting key hold
- local keyPressTime = nil -- Time when DEL key is first pressed
- local keyHeldDown = false -- Track if DEL is held down long enough
- local idleTimer = os.startTimer(2) -- Start 2-second idle timer to continue boot if no key is pressed
- while true do
- local event, param = os.pullEvent()
- if event == "key" then
- -- Reset idle timer whenever a key is pressed
- os.cancelTimer(idleTimer)
- idleTimer = os.startTimer(2) -- Start a new 2-second timer
- if param == keys.delete then
- if not keyPressTime then
- -- Mark the time when DEL is first pressed
- keyPressTime = os.clock()
- bootTimer = os.startTimer(3) -- Start a 3-second timer when DEL is pressed
- end
- keyHeldDown = true
- -- Show message when DEL is held
- showUEFIMessage("Keep pressing DEL to enter the startup menu")
- end
- elseif event == "key_up" then
- if param == keys.delete and keyHeldDown then
- local holdDuration = os.clock() - keyPressTime
- if holdDuration < 3 then
- -- If DEL is released before 3 seconds, continue boot process
- showUEFIMessage("DEL startup key released...")
- os.sleep(2.5)
- loadBootAnimation()
- return
- end
- keyPressTime = nil
- keyHeldDown = false
- end
- elseif event == "timer" then
- if param == bootTimer then
- -- If DEL is held for 3 seconds, load boot options
- showUEFIMessage("Loading startup menu...")
- os.sleep(2.5)
- shell.run("disk/boot/boot-options")
- return
- elseif param == idleTimer then
- -- If no key is pressed for 2 seconds, continue boot
- loadBootAnimation()
- return
- end
- end
- end
- end
- -- Run the main function
- main()
- -- Clear screen after shutdown
- term.setBackgroundColor(colors.black)
- term.clear()
- -- Load lockscreen
- shell.run("disk/os/lock.lua")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement