A basic code to manage your hacknets for you, while trying not to apend too much money.
Guide to Basic Hacknet Manager
How to Use
Make a .js file, or a .ns file. Either of those will work.
.script uses a different standard so those wont work.
Then paste the code into it.
The new file starts with some stuff all ready in it, so make sure you paste over it.
The Code
/** @param {NS} ns **/export async function main(ns) {function myMoney() {return ns.getServerMoneyAvailable("home");}//this script is designed to manage the hacknet nodes//to prevent excess spending i've limited it from spending//more than half the players moneyvar nodes = 0;var ref = 0;ns.disableLog("ALL");while (true) {//sleep for second to prevent the loop from crashing the gameawait ns.sleep(1000);//buy a node if we have more than twice the money neededif (ns.hacknet.getPurchaseNodeCost() < myMoney() / 2) {ref = ns.hacknet.purchaseNode();ns.print("bought node hn-" + ref);}nodes = ns.hacknet.numNodes()for (var i = 0; i < nodes; i++) {//check if nodes level is a multiple of 10var mod = ns.hacknet.getNodeStats(i).level % 10;//buy level node to the nearest multiple of 10 if we have double the money neededif (ns.hacknet.getLevelUpgradeCost(i, 10 - mod) < myMoney() / 2) {ns.hacknet.upgradeLevel(i, 10 - mod);ns.print("node hn-" + i + " leveled up");}//same for ramif (ns.hacknet.getRamUpgradeCost(i) < myMoney() / 2) {ns.hacknet.upgradeRam(i);ns.print("node hn-" + i + " ram upgraded");}//and coresif (ns.hacknet.getCoreUpgradeCost(i) < myMoney() / 2) {ns.hacknet.upgradeCore(i);ns.print("node hn-" + i + " core upgraded");}}}}
About Egor Opleuha7077 Articles
Egor Opleuha, also known as Juzzzie, is the Editor-in-Chief of Gameplay Tips. He is a writer with more than 12 years of experience in writing and editing online content. His favorite game was and still is the third part of the legendary Heroes of Might and Magic saga. He prefers to spend all his free time playing retro games and new indie games.
Related Articles
Bitburner – Unachievable Achievement Guide (How to Get Any Achievement)
With this guide you will learn how to obtain any achievement in the game, using only the game. Unachievable and Any Other Achievement You Want How-To It’s not cheating if […]
Bitburner – Exploit: Edit Achievement Guide
Some code to get the achievement hackers! How to Obtain Exploit: Edit Achievement How-To Instructions below! Go to your home computer and type this: Now just copy and paste the […]
Bitburner – Making the Most of Augmentations
A small checklist for new players who are nervous about Augmenting for the first time. Making The Most of Augmentations It may seem daunting at first, but as you progress […]