Advertisement
DOGGYWOOF

Untitled

Jul 25th, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. -- startup.lua
  2.  
  3. -- Function to clear the screen and set the background color
  4. local function clearScreen()
  5. term.clear()
  6. term.setBackgroundColor(colors.black)
  7. term.setTextColor(colors.white)
  8. end
  9.  
  10. -- Function to center and draw the ASCII art, additional text, and spinning wheel
  11. local function drawCenteredAsciiArtAndText()
  12. local artLines = {
  13. " _____^_",
  14. " | | \\",
  15. " \\ / ^ |",
  16. " / \\_/ 0 \\",
  17. " / \\",
  18. " / ____ 0",
  19. "/ / \\___ _/"
  20. }
  21.  
  22. local additionalText = "Doggy OS Pocket"
  23.  
  24. local screenWidth, screenHeight = term.getSize()
  25. local artWidth = 0
  26. local artHeight = #artLines
  27.  
  28. -- Calculate the width of the widest line in the ASCII art
  29. for _, line in ipairs(artLines) do
  30. artWidth = math.max(artWidth, #line)
  31. end
  32.  
  33. -- Calculate the width of the additional text
  34. local textWidth = #additionalText
  35.  
  36. -- Calculate starting positions
  37. local startX = math.floor((screenWidth - artWidth) / 2) + 1
  38. local startY = math.floor((screenHeight - artHeight - 2 - 2) / 2) + 1 -- -2 for art height and spacing, -2 for additional text and spacing
  39.  
  40. -- Draw ASCII art
  41. for i, line in ipairs(artLines) do
  42. term.setCursorPos(startX, startY + i - 1)
  43. term.setTextColor(colors.yellow)
  44. print(line)
  45. end
  46.  
  47. -- Draw additional text below ASCII art with 1 line spacing
  48. local textX = math.floor((screenWidth - textWidth) / 2) + 1
  49. local textY = startY + artHeight + 1 -- 1 line spacing
  50. term.setCursorPos(textX, textY)
  51. term.setTextColor(colors.white)
  52. print(additionalText)
  53.  
  54. -- Draw spinning wheel below additional text with 1 line spacing
  55. local wheelX = math.floor(screenWidth / 2) + 1
  56. local wheelY = textY + 1 -- 1 line spacing
  57. local wheelStates = {"|", "/", "-", "\\"}
  58. local wheelIndex = 1
  59.  
  60. while true do
  61. term.setCursorPos(wheelX, wheelY)
  62. term.setTextColor(colors.white)
  63. print(wheelStates[wheelIndex])
  64.  
  65. -- Update the wheel index
  66. wheelIndex = (wheelIndex % #wheelStates) + 1
  67.  
  68. -- Delay for animation effect
  69. os.sleep(0.1) -- Adjust the speed of the spinning wheel here
  70.  
  71. -- Clear the previous wheel position (optional)
  72. term.setCursorPos(wheelX, wheelY)
  73. term.setTextColor(colors.black)
  74. print(" ")
  75. end
  76. end
  77.  
  78. -- Main program
  79. clearScreen()
  80. drawCenteredAsciiArtAndText()
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement