bitburner-src/markdown/bitburner.ns.args.md
Snarling 08e71c732b
Threads are a positive integer (#366)
* Added new positive integer ns validation helper
* `run`, `exec`, and `spawn` verify threads as a positive integer.
* `run` terminal command also fails if the provided threadcount is not a positive integer.
* Removed some references to .script files in various documentation, and removed some of the NS1 example blocks
2023-02-14 01:32:01 -05:00

971 B

Home > bitburner > NS > args

NS.args property

Arguments passed into the script.

Signature:

readonly args: (string | number | boolean)[];

Remarks

RAM cost: 0 GB

Arguments passed into a script can be accessed as a normal array by using the [] operator (args[0], args[1], etc...). Arguments can be string, number, or boolean. Use args.length to get the number of arguments that were passed into a script.

Example

run example.js 7 text true

// example.js
export async function main(ns) {
  ns.tprint(ns.args.length) // 3
  ns.tprint(ns.args[0]); // 7 (number)
  ns.tprint(ns.args[1]); // "text" (string)
  ns.tprint(ns.args[2]); // true (boolean)
  ns.tprint(ns.args[3]); // undefined, because only 3 arguments were provided
}