alainbryden / bitburner-scripts

My own scripts for playing bitburner
MIT License
603 stars 271 forks source link

Downloading the whole repository

If you manually nano git-pull.js from the terminal and copy the contents of that script, you should be able to run it once and download the rest of the files I use. Early-game, many will be useless because they are only enabled by late-game features, but they shouldn't give you too many problems just being there.

Running scripts

If you run autopilot.js from the terminal, it will start several other scripts.

You can think of this as the "master orchestrator" script. It will kick off daemon.js (your primary hacking script), which in turn kicks off several other helper-scripts. It will monitor your progress throughout the game, and take special actions when it can. I don't want to spoil too much for those new to the game, but it's worth mentioning that SF4 is not required, but is highly-recommended to get the full benefit of this script.

Most scripts can also be run on their own, but are primarily designed to be orchestrated by autopilot.js or daemon.js.

Manually run scripts

Some scripts are meant to be manually run as needed. Most scripts take arguments to tweak or customize their behaviour based on your preferences or special circumstance. More on this below. Run scripts with the --help flag to get a list of their arguments, default values, and a brief description of each: image You will also see an error-version of this dialog if you make a mistake in how you run the script.

If you have personal preference and wish to "permanently" change the configuration of one of my scripts, you can do so without sacrificing your ability to "git-pull.js" the latest - simply create a custom config.txt file for the script.

Note: autopilot.js (and in turn, daemon.js) will already run many instances of scripts with default arguments. If you wish to run them with special arguments, you must either kill the default version or simply run scripts with your desired arguments before starting daemon.js. Daemon.js will only start scripts that are not already running (regardless of the arguments of the currently running instance.)

Brief description of Scripts

Here are scripts that you may want to manually run, roughly in the order in which you'll want to experiment with them:

If you want more information about any script, try reading the source. I do my best to document things clearly. If it's not clear, feel free to raise an issue.

Customizing Script Behaviour (Basic)

Most scripts are designed to be configured via command line arguments. (Such as using run host-manager.js --min-ram-exponent 8 to ensure no servers are purchased with less than 2^8 GB of RAM)

Default behaviours are to try to "balance" priorities and give most things an equal share of budget / RAM, but this isn't always ideal, especially in bitnodes that cripple one aspect of the game or the other. You can nano to view the script and see what the command line options are, or type e.g. daemon.js -- (dash dash) and hit <tab> to get a pop-up auto-completion list. (Make sure your mouse cursor is over the terminal for the auto-complete to appear.)

Near the top of the initializer for daemon.js, there are a list of external scripts that are spawned initially, and periodically. Some of these can be commented out if you would rather not have that script run automatically (for example work-for-factions if you would like to manually choose how to spend your "focus" times.) Once you've downloaded this file, you should customize it with the default options you like, and comment out the external scripts you don't want to run.

Aliases

You may find it useful to set up one or more aliases with the default options you like rather than editing the file itself. (Pro-tip, aliases support tab-auto-completion). I personally use the following aliases:

Config Files

Persistent Custom Configurations (script.js.config.txt files) can be specified to override the default args specified by the "args schema" in each script.

The order in which argument values are determined are:

  1. Arguments provided at the command line (or in the alias) take priority
  2. If no override is provided at the command line, any value in the config file is used.
  3. If no config file value is present, the default in the source (argsSchema) is used.
    • Note that some defaults are set to null in the args schema to be overridden with more complex defaulting behaviour elsewhere in the script.

Format Specifications

The file should have the name some-script-name.js.config.txt (i.e. append .config.txt to the name of the script you are configuring)

Your config file should either of the following two formats

  1. A dictionary e.g.: { "string-opt": "value", "num-opt": 123, "array-opt": ["one", "two"] }
  2. An array of dict entries (2-element arrays) e.g.: [ ["string-opt", "value"], ["num-opt", 123], ["array-opt", ["one", "two"]] ] +

You are welcome to use line breaks and spacing to make things more human readable, so long as it is able to be parsed by JSON.parse (when in doubt, built it in code and generate it with JSON.stringify).

Customizing Script Code (Advanced)

I encourage you to make a fork and customize scripts to your own needs / liking. Please don't make a PR back to me unless you truly think it's something all would benefit from. If you fork the repository, you can update the git-pull.js source to include your github account as the default, or set an alias that specifies this via command-line (e.g. alias git-pull="run git-pull.js --github mygitusername --repository bitburner-scripts). This way you can auto-update from your fork and only merge my latest changes when you're ready.

Disclaimer

This is my own repository of scripts for playing Bitburner. I often go to some lengths to make them generic and customizable, but am by no means providing these scripts as a "service" to the Bitburner community. It's meant as an easy way for me to share code with friends, and track changes and bugs in my scripts.

Hit up the Bitburner Discord with any questions:

Many helpful folks in there are familiar with my scripts or ones similar to them and can address your questions and concerns far quicker than I can.