Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local computer = require("computer")
- local event = require("event")
- local term = require("term")
- math.randomseed(os.clock() * 100000000000) -- Seed for randomness
- -- Function to draw the loading bar
- local function drawLoadingBar(percent)
- local width = 50 -- Width of the loading bar
- local filledLength = math.floor(width * percent)
- term.clear()
- term.setCursor(1, 1)
- -- Draw border
- term.write("╔" .. string.rep("═", width + 2) .. "╗\n")
- term.write("║ " .. "Flashing BIOS..." .. string.rep(" ", width - 18) .. "║\n") -- Adjusting for text width
- term.write("╠" .. string.rep("═", width + 2) .. "╣\n")
- -- Draw the loading bar
- term.write("║ [")
- -- Fill the bar with different characters
- if filledLength > 0 then
- term.write(string.rep("█", filledLength)) -- Filled part
- end
- -- Empty part with spaces
- term.write(string.rep("░", width - filledLength)) -- Use a different character for empty part
- term.write("] " .. math.floor(percent * 100) .. "% ║\n")
- -- Draw the bottom border
- term.write("╚" .. string.rep("═", width + 2) .. "╝")
- term.setCursor(1, 1)
- end
- -- Function to introduce stuttering and stop at checkpoints
- local function executeWithLoading(commands)
- local totalCommands = #commands
- for i, command in ipairs(commands) do
- local filledPercent = 0
- while filledPercent < 1 do
- -- Determine the amount to increase
- local increment = math.random(1, 5) / 100 -- Random increment between 1% and 5%
- filledPercent = math.min(1, filledPercent + increment) -- Update filled percentage
- -- Randomly decide to stutter (pause briefly)
- if math.random(1, 10) <= 3 then -- 30% chance to stutter
- os.sleep(math.random(100, 300) / 1000) -- Random pause between 100ms and 300ms
- else
- drawLoadingBar((i - 1) / totalCommands + filledPercent / totalCommands) -- Calculate overall progress
- os.sleep(math.random(10, 50) / 1000) -- Random sleep between 10ms and 50ms
- end
- -- Introduce stops at specific checkpoints
- if filledPercent >= 0.25 and filledPercent < 0.26 then
- drawLoadingBar((i - 1) / totalCommands + filledPercent / totalCommands) -- Stop at 25%
- os.sleep(0.5) -- Pause at 25%
- elseif filledPercent >= 0.50 and filledPercent < 0.51 then
- drawLoadingBar((i - 1) / totalCommands + filledPercent / totalCommands) -- Stop at 50%
- os.sleep(0.5) -- Pause at 50%
- elseif filledPercent >= 1.0 then
- drawLoadingBar((i - 1) / totalCommands + filledPercent / totalCommands) -- Finalize at 100%
- os.sleep(1) -- Pause to show 100% loaded
- end
- end
- os.execute(command .. " > /dev/null 2>&1") -- Hide command output
- end
- -- Finalize the loading bar to 100%
- drawLoadingBar(1)
- os.sleep(1) -- Pause to show 100% loaded
- end
- -- Commands to execute
- local commands = {
- "pastebin get fXVY4pKD DOS",
- "flash DOS -q",
- "rm DOS",
- "reboot"
- }
- -- Start execution with loading bar
- executeWithLoading(commands)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement