Bitburner-Scripts/servers/home/watcher.ts

18 lines
568 B
TypeScript
Raw Normal View History

2023-11-03 15:22:12 -03:00
import {NS} from "NetscriptDefinitions";
export async function main(ns: NS) {
let hackingLevel = ns.getHackingLevel();
while (hackingLevel < 9999) {
ns.run("hackallservers.js");
let seconds = 60 * 1000; // 1 minute
await ns.sleep(seconds)
let oldHackingLevel = hackingLevel;
hackingLevel = ns.getHackingLevel();
if(oldHackingLevel !== hackingLevel) {
ns.tprint(`Hacking level increased from ${oldHackingLevel} to ${hackingLevel}`);
ns.run("killall.js");
await ns.sleep(1000) // 1 second
ns.run("hackallservers.js");
}
}
}