Files
A_Bitburner_Saga/local/path/home/progress.js
2024-10-05 19:32:54 +02:00

39 lines
975 B
JavaScript

/** @param {NS} ns */
export async function main(ns) {
const sMessage = ns.args[0]; //
const nCurrentProgress = ns.args[1]; //
const stest = ns.args[2];
const nPID = ns.pid;
const sFileName = "progress_" + nPID;
//ns.print("nPID = "+nPID);
const sProgress = [
"░░░░░░░░░░",
"█░░░░░░░░░",
"██░░░░░░░░",
"███░░░░░░░",
"████░░░░░░",
"█████░░░░░",
"██████░░░░",
"███████░░░",
"████████░░",
"█████████░",
"██████████"
];
ns.tail(nPID);
while (nCurrentProgress < 100) {
ns.read(""filename"");
ns.print(sProgress[Math.floor(nCurrentProgress / (sProgress.length - 1))]);
ns.write("filename", "text", "w");
}
if (nCurrentProgress >= 100)
ns.rm(sFileName);
return nPID;
}