By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
Fadgames.net
  • Apps
  • Tools
  • Software
  • Photoshop
  • Download
  • Guides
  • Cheats
Notification
Fadgames.netFadgames.net
Aa
Search

Top Post

The Texas Chain Saw Massacre Beginners Guide

The Texas Chain Saw Massacre My character not leveling up anymore

Photo Generic Guide

Bomb Rush Cyberfunk Photo Generic Guide (Polo Locations)

Stay Connected

Find us on socials
248.1k Followers Like
61.1k Followers Follow
165k Subscribers Subscribe
Made by ThemeRuby using the Foxiz theme. Powered by WordPress
Home » Blog » Bitburner: How to Add Custom Stats to the HUD (Heads up Display)
Guides

Bitburner: How to Add Custom Stats to the HUD (Heads up Display)

Jaeden Feil
Last updated: 2023/07/17 at 5:22 AM
By Jaeden Feil
Share
SHARE

Customise your stats HUD using secret built-in hooks, and a little bit of scripting.

Contents
Poking AroundSample Code

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"

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)

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:

By In-sight-

TAGGED: BITBURNER
Jaeden Feil July 17, 2023 July 17, 2023
Share This Article
Facebook Twitter Copy Link Print

Related

Guides

The Texas Chain Saw Massacre Beginners Guide

Guides

The Texas Chain Saw Massacre My character not leveling up anymore

Photo Generic Guide
Guides

Bomb Rush Cyberfunk Photo Generic Guide (Polo Locations)

Guides

Character Guide | Touhou Juuouen Unfinished Dream of All Living Ghost

Guides

Book of Hours How to get unstuck

Guides

Princess & Conquest The Acquisition of Capital

Guides

Book of Hours Assistance Guide

Guides

VPet-Simulator AHK script to remove the window from the ALT-Tab list

Show More
Fadgames.net

All Guides, Walkthrough, Tips, Cheats for You

  • About Us
  • Privacy Policy
  • Terms and Conditions
  • Contact Us
Made by ThemeRuby using the Foxiz theme. Powered by WordPress
Welcome Back!

Sign in to your account

Register Lost your password?