A guide on how to do autocomplete scripts (vs code) in Bitburner.
How to Do Autocomplete Scripts
How to Do It
- Create a new empty folder/directory for your scripts.
- Go to the games official github, and download the “NetscriptDefinitions.d.ts” file.
- Put this file in your script directory.
- Rename the file to “index.d.ts”.
- Open the folder in VS Code.
- Make a new file for your new script. In this example, we’ll call it “hack.js”.
- You now have two options…
Both options do the same thing, but different ways. Pick your poison.
Option 1: JSDoc Params
This option uses a JSDoc params tag on every function that uses the `NS` object type.
/** @param {import(".").NS } ns */
export async function main(ns) {
// you now have autocomplete for all `ns.` commands.
const hackingLevel = ns.getHackingLevel();
}
Option 2: JSDoc Type
This option uses a JSDoc type tag on a global `ns` object. This is safe, internally its the same object being reused anyways.
/** @type import(".").NS */
let ns = null;
export async function main(_ns) {
ns = _ns;
// you now have autocomplete for all `ns.` commands.
const hackingLevel = ns.getHackingLevel();
}
by Pobiega
Similar Posts:
- Bitburner – How to Get Any Achievement Guide
- Bitburner – How to Print with Using Color
- Bitburner – Making Cat Viewer Program Guide
- Bitburner – How to Auto Hack Script (Auto-Farm)