HomeGame GuidesHow To Autocomplete your scripts in VS Code - Bitburner

How To Autocomplete your scripts in VS Code – Bitburner

Published on

ADVERTISEMENT

By Pobiega

A short guide that describes how to set up autocompletion for the games own code classes inside Visual Studio Code, so you can write your scripts outside of the game.

How to do it.

  1. Create a new empty folder/directory for your scripts.
  2. Go to the games official github, and download the “NetscriptDefinitions.d.ts” file: https://github.com/danielyxie/bitburner/blob/dev/src/ScriptEditor/NetscriptDefinitions.d.ts
  3. Put this file in your script directory.
  4. Rename the file to “index.d.ts”.
  5. Open the folder in VS Code.
  6. Make a new file for your new script. In this example, we’ll call it “hack.js”.
  7. 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();

}

Latest articles

When is the discharge date of Scorn?

After a seeing a launch date delay that led to its justifiable share of...

Magical Drop VI to see the charming puzzler return on Nintendo Switch – SteamGamers

Good Fortune Fun information for retro block-busting followers this week, as publisher Forever Entertainment has...

5 Letter Words with SCO in Them – Wordle Clue

There are lots of enjoyable phrase video games to play, just like...

The Gathering Introduces The Child Creature Type, With Unfortunate Consequences

Magic: The Gathering’s Unfinity is a parody set stuffed with all types of bizarre,...
ADVERTISEMENT

More like this

When is the discharge date of Scorn?

After a seeing a launch date delay that led to its justifiable share of...

Magical Drop VI to see the charming puzzler return on Nintendo Switch – SteamGamers

Good Fortune Fun information for retro block-busting followers this week, as publisher Forever Entertainment has...

5 Letter Words with SCO in Them – Wordle Clue

There are lots of enjoyable phrase video games to play, just like...