Skip to content

Instantly share code, notes, and snippets.

View Spartelfant's full-sized avatar

Bart Kuijper Spartelfant

  • The Netherlands
View GitHub Profile
@Spartelfant
Spartelfant / quickSpawn.js
Last active October 6, 2022 15:27
Bitburner ns2 script: a script to spawn any script without the 10-second delay imposed by ns.spawn()
/**
* Executes a script after a specified delay in milliseconds.
*
* This script takes a delay (in milliseconds) as its first argument, followed by the same arguments as ns.run().
*
* For example, to spawn a script with 4 threads after a 10 millisecond delay using the same arguments as the calling script:
* ns.run('quickSpawn.js', 1, 10, 'scriptToSpawn.js', 4, ...ns.args);
*
* @param {NS} ns
*/
@Spartelfant
Spartelfant / colors.js
Last active March 7, 2026 12:14
Bitburner ns2 script: A quick reference to all colors, printed to the terminal.
/** @param {NS} ns */
export async function main(ns) {
ns.disableLog(`ALL`); // Failures are still logged, this just prevents unnecessary log spam.
ns.tprintf(`\x1b[1;35mUsing colors in script output with \x1b[1;36mtprint\x1b[1;35m & \x1b[36;1mtprintf\x1b[1;35m (terminal) and \x1b[36;1mprint\x1b[1;35m & \x1b[1;36mprintf\x1b[1;35m (log)`);
ns.tprintf(`\n`);
ns.tprintf(`\x1b[1;36m• Using a 4-letter all-CAPS keyword at the start of the string you're printing`);
ns.tprintf(`This gives 4 foreground colors, which can be changed in the game's theme settings.`);