Advertisement
DOGGYWOOF

Installer

Jul 24th, 2024 (edited)
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2.  
  3. -- Center the text within the given width
  4. function centerText(text, width)
  5. local padding = math.max(0, math.floor((width - #text) / 2))
  6. return string.rep(" ", padding) .. text
  7. end
  8.  
  9. -- Draw a border with specified width and height
  10. function drawBorder(width, height)
  11. term.setCursorPos(1, 1)
  12. term.write("+" .. string.rep("-", width - 2) .. "+")
  13. for i = 2, height - 1 do
  14. term.setCursorPos(1, i)
  15. term.write("|")
  16. term.setCursorPos(width, i)
  17. term.write("|")
  18. end
  19. term.setCursorPos(1, height)
  20. term.write("+" .. string.rep("-", width - 2) .. "+")
  21. end
  22.  
  23. -- Draw the centered text with more spacing
  24. function drawCenteredText(width, height)
  25. term.setCursorPos(2, 2)
  26. drawBorder(width, height)
  27.  
  28. local y = 4
  29. term.setCursorPos(3, y)
  30. print(centerText("Doggy OS Installation Media", width - 4))
  31.  
  32. y = y + 2
  33. term.setCursorPos(3, y)
  34. print(centerText("OS VERSION: Doggy OS 13.0", width - 4))
  35.  
  36. y = y + 1
  37. term.setCursorPos(3, y)
  38. print(centerText("UEFI: N3K0 UEFI", width - 4))
  39.  
  40. y = y + 1
  41. term.setCursorPos(3, y)
  42. print(centerText("BOOTLOADER: VA11-ILLA 12.0", width - 4))
  43.  
  44. y = y + 3
  45. term.setCursorPos(3, y)
  46. print(centerText("Confirm Install", width - 4))
  47.  
  48. y = y + 1
  49. term.setCursorPos(3, y)
  50. print(centerText("Y: Install OS", width - 4))
  51.  
  52. y = y + 1
  53. term.setCursorPos(3, y)
  54. print(centerText("N: Cancel Install", width - 4))
  55.  
  56. y = y + 3
  57. term.setCursorPos(3, y)
  58. print(centerText("===================================", width - 4))
  59. end
  60.  
  61. function main()
  62. term.clear()
  63. local w, h = term.getSize()
  64. local contentHeight = 16
  65. local borderPadding = 2 -- Padding between border and content
  66.  
  67. -- Adjust height for border padding
  68. local heightWithBorders = contentHeight + borderPadding * 2
  69.  
  70. -- Make sure the height fits within the screen
  71. local displayHeight = math.min(h, heightWithBorders)
  72. drawCenteredText(w, displayHeight)
  73.  
  74. -- Read user input
  75. term.setCursorPos(3, displayHeight - 1)
  76. local user_input = read()
  77.  
  78. if user_input:lower() == 'y' then
  79. runProgram()
  80. elseif user_input:lower() == 'n' then
  81. term.clear()
  82. term.setCursorPos(1, 1)
  83. drawBorder(w, 7)
  84. term.setCursorPos(3, 2)
  85. print(centerText("The Installation Was Cancelled!", w - 4))
  86. term.setCursorPos(3, 3)
  87. print(centerText("Shutting Down...", w - 4))
  88. sleep(4)
  89. os.shutdown()
  90. else
  91. shell.run("/disk/startup")
  92. main()
  93. end
  94. end
  95.  
  96. function runProgram()
  97. -- Replace the following line with the code to run your desired program
  98. shell.run("/disk/install") -- Replace with your actual program name
  99. end
  100.  
  101. main()
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement