forked from bitburner-official/bitburner-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-stats.js
35 lines (33 loc) · 1.35 KB
/
custom-stats.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
/** @param {NS} ns **/
export async function main(ns) {
const args = ns.flags([["help", false]]);
if (args.help) {
ns.tprint("This script will enhance your HUD (Heads up Display) with custom statistics.");
ns.tprint(`Usage: run ${ns.getScriptName()}`);
ns.tprint("Example:");
ns.tprint(`> run ${ns.getScriptName()}`);
return;
}
const doc = document; // This is expensive! (25GB RAM) Perhaps there's a way around it? ;)
const hook0 = doc.getElementById('overview-extra-hook-0');
const hook1 = doc.getElementById('overview-extra-hook-1');
while (true) {
try {
const headers = []
const values = [];
// Add script income per second
headers.push("ScrInc");
values.push(ns.getScriptIncome()[0].toPrecision(5) + '/sec');
// Add script exp gain rate per second
headers.push("ScrExp");
values.push(ns.getScriptExpGain().toPrecision(5) + '/sec');
// TODO: Add more neat stuff
// Now drop it into the placeholder elements
hook0.innerText = headers.join(" \n");
hook1.innerText = values.join("\n");
} catch (err) { // This might come in handy later
ns.print("ERROR: Update Skipped: " + String(err));
}
await ns.sleep(1000);
}
}