bitburner-src/markdown/bitburner.ns.md

9.7 KiB
Raw Blame History

Home > bitburner > NS

NS interface

Collection of all functions passed to scripts

Signature:

export interface NS extends Singularity 

Extends: Singularity

Properties

Property Type Description
args (string | number)[] Arguments passed into the script.
bladeburner Bladeburner Namespace for bladeburner related functions.
codingcontract CodingContract Namespace for codingcontract related functions.
gang Gang Namespace for gang related functions.
hacknet Hacknet Namespace for hacknet related functions.
sleeve Sleeve Namespace for sleeve related functions.
stock TIX Namespace for stock related functions.

Methods

Method Description
brutessh(host) Runs BruteSSH.exe on a server.
clear(handle) Clear data from a port.
clearLog() Clears the scripts logs.
deleteServer(host) Delete a purchased server.
disableLog(fn) Disables logging for the given function.
enableLog(fn) Enable logging for a certain function.
exec(script, host, numThreads, args) Start another script on any server.
exit() Terminates the current script immediately.
fileExists(filename, host) Check if a file exists.
ftpcrack(host) Runs FTPCrack.exe on a server.
getBitNodeMultipliers() Get the current Bitnode multipliers.
getFavorToDonate() Returns the amount of Faction favor required to be able to donate to a faction.
getGrowTime(host) Get the execution time of a grow() call.
getHackingLevel() Returns the players current hacking level.
getHackingMultipliers() Get hacking related multipliers.
getHacknetMultipliers() Get hacknet related multipliers.
getHackTime(host) Get the execution time of a hack() call.
getHostname() Returns a string with the hostname of the server that the script is running on.
getPortHandle(port) Get all data on a port.
getPurchasedServerCost(ram) Get cost of purchasing a server.
getPurchasedServerLimit() Returns the maximum number of servers you can purchase.
getPurchasedServerMaxRam() Returns the maximum RAM that a purchased server can have.
getPurchasedServers(hostnameMode) Returns an array with either the hostnames or IPs of all of the servers you have purchased.
getScriptExpGain(script, host, args) Get the exp gain of a script.
getScriptIncome(script, host, args) Get the income of a script.
getScriptLogs(fn, host, args) Get all the logs of a script.
getScriptName() Returns the current script name.
getScriptRam(script, host) Get the ram cost of a script.
getServer(host) Returns a server object for the given server. Defaults to the running script's server if host is not specified.
getServerGrowth(host) Get a server growth parameter.
getServerMaxMoney(host) Get maximum money available on a server.
getServerMinSecurityLevel(host) Returns the minimum security level of the target server.
getServerMoneyAvailable(host) Get money available on a server.
getServerNumPortsRequired(host) Returns the number of open ports required to successfully run NUKE.exe on the specified server.
getServerRequiredHackingLevel(host) Returns the required hacking level of the target server.
getServerSecurityLevel(host) Get server security level.
getTimeSinceLastAug() Returns the amount of time in milliseconds that have passed since you last installed Augmentations.
getWeakenTime(host) Get the execution time of a weaken() call.
grow(host, opts) Spoof money in a servers bank account, increasing the amount available.
growthAnalyze(host, growthAmount) Calculate the number of grow thread needed to grow a server by a certain multiplier.
growthAnalyzeSecurity(threads) Calculate the security increase for a number of thread.
hack(host, opts) Steal a servers money.
hackAnalyzePercent(host) Get the percent of money stolen with a single thread.
hackAnalyzeSecurity(threads) Get the security increase for a number of thread.
hackAnalyzeThreads(host, hackAmount) Predict the effect of hack.
hackChance(host) Get the chance of successfully hacking a server.
hasRootAccess(host) Check if your have root access on a server.
httpworm(host) Runs HTTPWorm.exe on a server.
isLogEnabled(fn) Checks the status of the logging for the given function.
isRunning(script, host, args) Check if a script is running.
kill(script, host, args) Terminate another script.
kill(scriptPid) Terminate another script.
killall(host) Terminate all scripts on a server.
ls(host, grep) List files on a server.
nFormat(n, format) Format a number
nuke(host) Runs NUKE.exe on a server.
peek(port) Get a copy of the data from a port without popping it.
print(msg) Prints a value or a variable to the scripts logs.
prompt(txt) Prompt the player with a Yes/No modal.
ps(host) List running scripts on a server.
purchaseServer(hostname, ram) Purchase a server.
read(handle) Read content of a file.
relaysmtp(host) Runs relaySMTP.exe on a server.
rm(name, host) Delete a file.
run(script, numThreads, args) Start another script on the current server.
scan(host, hostnames) Get the list servers connected to a server.
scp(files, destination) Copy file between servers.
scp(files, source, destination) Copy file between servers.
scriptKill(script, host) Kill all scripts with a filename.
scriptRunning(script, host) Check if any script with a filename is running.
serverExists(host) Returns a boolean denoting whether or not the specified server exists.
sleep(millis) Suspends the script for n milliseconds.
spawn(script, numThreads, args) Terminate current script and start another in 10s.
sprintf(format, args) Format a string.
sqlinject(host) Runs SQLInject.exe on a server.
tail(fn, host, args) Open the tail window of a script.
tprint(msg) Prints a value or a variable to the Terminal.
tryWrite(port, data) Attempt to write to a port.
vsprintf(format, args) Format a string with an array of arguments.
weaken(host, opts) Reduce a server security level.
weakenAnalyze(threads, cores) Predict the effect of weaken.
wget(url, target, host) Download a file from the internet.
write(handle, data, mode) Write data to a file.