20 KiB
NS interface
Collection of all functions passed to scripts
Signature:
export interface NS
Remarks
Basic usage example:
export async function main(ns) {
// Basic ns functions can be accessed on the ns object
ns.getHostname();
// Some related functions are gathered under a sub-property of the ns object
ns.stock.getPrice();
// Most functions that return a promise need to be awaited.
await ns.hack('n00dles');
}
Properties
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
|
Arguments passed into the script. | ||
|
|
Namespace for Bladeburner functions. Contains spoilers. | ||
|
|
Namespace for cloud functions. | ||
|
|
Namespace for coding contract functions. | ||
|
|
Namespace for corporation functions. Contains spoilers. | ||
|
|
Namespace for darknet functions. Contains spoilers. | ||
|
|
Namespace for formatting functions. | ||
|
|
Namespace for formulas functions. | ||
|
|
Namespace for gang functions. Contains spoilers. | ||
|
|
Namespace for Go functions. | ||
|
|
Namespace for grafting functions. Contains spoilers. | ||
|
|
Namespace for hacknet functions. Some of this API contains spoilers. | ||
|
|
{ break(): number; } | ||
|
|
Namespace for infiltration functions. | ||
|
|
number |
The current script's PID | |
|
|
Namespace for singularity functions. Contains spoilers. | ||
|
|
Namespace for sleeve functions. Contains spoilers. | ||
|
|
Namespace for Stanek functions. Contains spoilers. | ||
|
|
Namespace for stock functions. | ||
|
|
Namespace for user interface functions. |
Methods
|
Method |
Description |
|---|---|
|
Open up a message box. | |
|
Suspends the script for n milliseconds. Doesn't block with concurrent calls. | |
|
Add a callback to be executed when the script dies. | |
|
Runs BruteSSH.exe on a server. | |
|
Clear data from a file. | |
|
Clears the script’s logs. | |
|
Clear data from a port. | |
|
Disables logging for the given NS function. | |
|
Given a hostname, returns its IP address; or given an IP address, returns its hostname. | |
|
Dynamically import a script. Only scripts located on the same server can be imported. A dynamic import will not adjust RAM usage. This must be done manually with ramOverride. | |
|
Enables logging for the given NS function. | |
|
Start another script on any server. | |
|
Terminates the current script immediately. | |
|
Check if a file exists. | |
|
Parse command line flags. | |
|
Runs FTPCrack.exe on a server. | |
|
Get the current BitNode multipliers. | |
|
Returns the amount of Faction favor required to be able to donate to a faction. | |
|
Get the metadata of a file. | |
|
Get the ram cost of a netscript function. | |
|
Get the execution time of a grow() call. | |
|
Returns the player’s current hacking level. | |
|
Get hacking related multipliers. | |
|
Get hacknet related multipliers. | |
|
Get the execution time of a hack() call. | |
|
Returns a string with the hostname of the server that the script is running on. | |
|
Returns a string with the IP address of the server that the script is running on. | |
|
Get information about the sources of income for this run. | |
|
Get information about the player. | |
|
Get all data on a port. | |
|
Get an array of recently killed scripts across all servers. | |
|
Get information about resets. | |
|
Get general info about a running script. | |
|
Get the exp gain of a script. | |
|
Get the income of a script. | |
|
Get all the logs of a script. | |
|
Returns the current script name. | |
|
Get the ram cost of a script. | |
|
Returns data of a server. If the server is a darknet server and has recently gone offline, it will return a dummy server object with | |
|
Get the base security level of a server. | |
|
Get a server growth parameter. | |
|
Get the maximum money available on a server. | |
|
Get the maximum amount of RAM on a server. | |
|
Returns the minimum security level of the target server. | |
|
Get money available on a server. | |
|
Returns the number of open ports required to successfully run NUKE.exe on the specified server. | |
|
Returns the required hacking level of the target server. | |
|
Get server security level. | |
|
Get the used RAM on a server. This includes ram used by running scripts as well as blocked ram on darknet servers. | |
|
Share power has a multiplicative effect on rep/second while doing hacking work for a faction. If you do non-hacking work, share power still increases the reputation gain rate, but the effect is non-linear. Share power increases incrementally for every thread of share running on your server network, but at a sharply decreasing rate. | |
|
Get the exp gain of all scripts. | |
|
Get the income of all scripts. | |
|
Get the execution time of a weaken() call. | |
|
Spoof money in a server's bank account, increasing the amount available. | |
|
Calculate the number of grow threads needed for a given multiplicative growth factor. | |
|
Calculate the security increase for a number of grow threads. | |
|
Steal a server's money. | |
|
Get the part of money stolen with a single thread. | |
|
Get the chance of successfully hacking a server. | |
|
Get the security increase for a number of threads. | |
|
Calculate the decimal number of threads needed to hack a specified amount of money from a target host. | |
|
Check if you have root access on a server. | |
|
Returns whether the player has access to the darkweb. | |
|
Runs HTTPWorm.exe on a server. | |
|
Checks the status of the logging for the given NS function. | |
|
Check if a script is running. | |
|
Terminate the script with the provided PID. | |
|
Terminate the script(s) with the provided filename, host, and script arguments. | |
|
Terminate all scripts on a server. | |
|
List files on a server. | |
|
Move a file on the target server. | |
|
Listen for a port write. | |
|
Runs NUKE.exe on a server. | |
|
Get a copy of the data from a port without popping it. | |
|
Prints one or more values or variables to the script’s logs. | |
|
Prints a formatted string to the script’s logs. | |
|
Prints a ReactNode to the script logs. | |
|
Prompt the player with an input modal. | |
|
List running scripts on a server. | |
|
Change the current static RAM allocation of the script. | |
|
Read content of a file. | |
|
Read data from a port. | |
|
Runs relaySMTP.exe on a server. | |
|
Delete a file. | |
|
Start another script on the current server. | |
|
Get the list of hostnames or IP addresses connected to a server. This function does not return darknet servers (e.g., darkweb). Use probe if you want to list darknet servers. | |
|
Copy file between servers. | |
|
Kill all scripts with a filename. | |
|
Check if any script with a filename is running. | |
|
Returns the currently running script. | |
|
Returns a boolean denoting whether or not the specified server exists. | |
|
Share the server's ram with your factions to increase the reputation gain rate of faction work. This boost is applied to all faction work of all factions. | |
|
Suspends the script for n milliseconds. | |
|
Terminate current script and start another in a defined number of milliseconds. | |
|
Format a string. | |
|
Runs SQLInject.exe on a server. | |
|
Queue a toast (bottom-right notification). | |
|
Prints one or more values or variables to the Terminal. | |
|
Prints a raw value or a variable to the Terminal. | |
|
Prints a ReactNode to the terminal. | |
|
Attempt to write to a port. | |
|
Format a string with an array of arguments. | |
|
Reduce a server's security level. | |
|
Predict the effect of weaken. | |
|
Download a file from the internet. | |
|
Write data to a file. | |
|
Write data to a port. |