forked from bitburner-official/bitburner-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor.js
35 lines (34 loc) · 1.51 KB
/
monitor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
export async function main(ns) {
const flags = ns.flags([
['refreshrate', 200],
['help', false],
])
if (flags._.length === 0 || flags.help) {
ns.tprint("This script helps visualize the money and security of a server.");
ns.tprint(`USAGE: run ${ns.getScriptName()} SERVER_NAME`);
ns.tprint("Example:");
ns.tprint(`> run ${ns.getScriptName()} n00dles`)
return;
}
ns.tail();
ns.disableLog('ALL');
while (true) {
const server = flags._[0];
let money = ns.getServerMoneyAvailable(server);
if (money === 0) money = 1;
const maxMoney = ns.getServerMaxMoney(server);
const minSec = ns.getServerMinSecurityLevel(server);
const sec = ns.getServerSecurityLevel(server);
ns.clearLog(server);
ns.print(`${server}:`);
ns.print(` $_______: ${ns.nFormat(money, "$0.000a")} / ${ns.nFormat(maxMoney, "$0.000a")} (${(money / maxMoney * 100).toFixed(2)}%)`);
ns.print(` security: +${(sec - minSec).toFixed(2)}`);
ns.print(` hack____: ${ns.tFormat(ns.getHackTime(server))} (t=${Math.ceil(ns.hackAnalyzeThreads(server, money))})`);
ns.print(` grow____: ${ns.tFormat(ns.getGrowTime(server))} (t=${Math.ceil(ns.growthAnalyze(server, maxMoney / money))})`);
ns.print(` weaken__: ${ns.tFormat(ns.getWeakenTime(server))} (t=${Math.ceil((sec - minSec) * 20)})`);
await ns.sleep(flags.refreshrate);
}
}
export function autocomplete(data, args) {
return data.servers;
}