Advertisement
DOGGYWOOF

Doggy Bootloader installer

Nov 1st, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. local component = require("component")
  2. local computer = require("computer")
  3. local event = require("event")
  4. local term = require("term")
  5. math.randomseed(os.clock() * 100000000000) -- Seed for randomness
  6.  
  7. -- Function to draw the loading bar
  8. local function drawLoadingBar(percent)
  9. local width = 50 -- Width of the loading bar
  10. local filledLength = math.floor(width * percent)
  11.  
  12. term.clear()
  13. term.setCursor(1, 1)
  14.  
  15. -- Draw border
  16. term.write("╔" .. string.rep("═", width + 2) .. "╗\n")
  17. term.write("║ " .. "Flashing BIOS..." .. string.rep(" ", width - 18) .. "║\n") -- Adjusting for text width
  18. term.write("╠" .. string.rep("═", width + 2) .. "╣\n")
  19.  
  20. -- Draw the loading bar
  21. term.write("║ [")
  22.  
  23. -- Fill the bar with different characters
  24. if filledLength > 0 then
  25. term.write(string.rep("█", filledLength)) -- Filled part
  26. end
  27.  
  28. -- Empty part with spaces
  29. term.write(string.rep("░", width - filledLength)) -- Use a different character for empty part
  30.  
  31. term.write("] " .. math.floor(percent * 100) .. "% ║\n")
  32.  
  33. -- Draw the bottom border
  34. term.write("╚" .. string.rep("═", width + 2) .. "╝")
  35. term.setCursor(1, 1)
  36. end
  37.  
  38. -- Function to introduce stuttering and stop at checkpoints
  39. local function executeWithLoading(commands)
  40. local totalCommands = #commands
  41.  
  42. for i, command in ipairs(commands) do
  43. local filledPercent = 0
  44.  
  45. while filledPercent < 1 do
  46. -- Determine the amount to increase
  47. local increment = math.random(1, 5) / 100 -- Random increment between 1% and 5%
  48. filledPercent = math.min(1, filledPercent + increment) -- Update filled percentage
  49.  
  50. -- Randomly decide to stutter (pause briefly)
  51. if math.random(1, 10) <= 3 then -- 30% chance to stutter
  52. os.sleep(math.random(100, 300) / 1000) -- Random pause between 100ms and 300ms
  53. else
  54. drawLoadingBar((i - 1) / totalCommands + filledPercent / totalCommands) -- Calculate overall progress
  55. os.sleep(math.random(10, 50) / 1000) -- Random sleep between 10ms and 50ms
  56. end
  57.  
  58. -- Introduce stops at specific checkpoints
  59. if filledPercent >= 0.25 and filledPercent < 0.26 then
  60. drawLoadingBar((i - 1) / totalCommands + filledPercent / totalCommands) -- Stop at 25%
  61. os.sleep(0.5) -- Pause at 25%
  62. elseif filledPercent >= 0.50 and filledPercent < 0.51 then
  63. drawLoadingBar((i - 1) / totalCommands + filledPercent / totalCommands) -- Stop at 50%
  64. os.sleep(0.5) -- Pause at 50%
  65. elseif filledPercent >= 1.0 then
  66. drawLoadingBar((i - 1) / totalCommands + filledPercent / totalCommands) -- Finalize at 100%
  67. os.sleep(1) -- Pause to show 100% loaded
  68. end
  69. end
  70.  
  71. os.execute(command .. " > /dev/null 2>&1") -- Hide command output
  72. end
  73.  
  74. -- Finalize the loading bar to 100%
  75. drawLoadingBar(1)
  76. os.sleep(1) -- Pause to show 100% loaded
  77. end
  78.  
  79. -- Commands to execute
  80. local commands = {
  81. "pastebin get fXVY4pKD DOS",
  82. "flash DOS -q",
  83. "rm DOS",
  84. "reboot"
  85. }
  86.  
  87. -- Start execution with loading bar
  88. executeWithLoading(commands)
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement