Skip to content
Menu
SteamAH
  • Cheat
  • Guide
  • Tips
  • Game Lists
  • Privacy Policy
  • Abuse
SteamAH

Bitburner How to Adding Custom Stats to HUD

Posted on December 13, 2021

If you want to see more info on you HUD, this guide will show you how to Customise your stats HUD using secret built-in hooks, and a little bit of scripting.

Poking Around

This game encourages you to look beyond the UI, beyond the documentation. You’re encouraged to inspect the DOM, and even look at the source code itself. You’ll find there’s much you can do once you start thinking outside the box.

For example, a quick look at the stats HUD (heads-up-display) section of the UI will reveal that there is an empty section:

id=”overview-extra-hook-0″

Bitburner How to Adding Custom Stats to HUD

It was placed there deliberately to allow any sort of custom stat you like to be added to this UI element.

Sample Code

Did you know you can access the document (UI) from within the game itself? With a little bit of scripting you can hook these placeholder elements and put whatever you want in them. Here’s an example:

nano custom-stats.js
/** @param {NS} ns **/
export async function main(ns) {
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);
}
}

Here’s what it looks like coded up in-game (Steam’s rendering of code isn’t the greatest)
Bitburner How to Adding Custom Stats to HUD

READ:  Bitburner How to Get 100% Achievement Unlocked

Run your program from the terminal (make sure you have enough free RAM):

run custom-stats.js

And there you have it, custom stats on the HUD, updated every second:
Bitburner How to Adding Custom Stats to HUD

That’s all we are sharing today in Bitburner How to Adding Custom Stats to HUD, if you have anything to add, please feel free to leave a comment below, you can also read the original article here, all the credits goes to the original author In-sight-

MORE GAME GUIDES FOR YOU

Related Posts:

  • Bitburner How to Minimize Button
  • Bitburner How to Get 100% Achievement Unlocked
  • Bitburner Early Game Progression Guide

1 thought on “Bitburner How to Adding Custom Stats to HUD”

  1. wrxmarcus says:
    January 30, 2022 at am10:35

    This is great.
    I was wondering if you’re found a way to display Karma?
    Thanks!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Disclaimer

All content cited is derived from their respective sources. If you think we have used your content without permission, Please go to the Abuse Page to contact us and we will be taking it seriously.

Recent Posts

  • Planet Fights Everything ou Need to Know about Agent Fights
  • Planet Fights Space Colonies Explained
  • Planet Fights International Battlefields Guide
  • Deceive Inc 10 Tips to Help You in Your Mission
  • Sons Of The Forest How to Make Trees Auto Respawn without Mods
©2023 SteamAH | Powered by SuperbThemes & WordPress