bitburner-src/markdown/bitburner.ns.md
Olivier Gagnon 42518c3caa fix few bugs
2021-11-22 11:36:13 -05:00

11 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 functions.
codingcontract CodingContract Namespace for codingcontract functions.
formulas Formulas Namespace for formulas functions.
gang Gang Namespace for gang functions.
hacknet Hacknet Namespace for hacknet functions.
sleeve Sleeve Namespace for sleeve functions.
stock TIX Namespace for stock functions.

Methods

Method Description
alert(msg) Open up a message box.
asleep(millis) Suspends the script for n milliseconds. Doesn't block with concurrent calls.
atExit(f) Add callback function when the script dies
brutessh(host) Runs BruteSSH.exe on a server.
clear(handle) Clear data from a file.
clearLog() Clears the scripts logs.
clearPort(handle) Clear data from a port.
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.
flags(schema) Parse command line flags.
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.
getPlayer() Get information about the player.
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.
getRunningScript(filename, hostname, args) Get general info about a running script.
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.
getServerBaseSecurityLevel(host)
getServerGrowth(host) Get a server growth parameter.
getServerMaxMoney(host) Get maximum money available on a server.
getServerMaxRam(host) Get the max RAM 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.
getServerRam(host)
getServerRequiredHackingLevel(host) Returns the required hacking level of the target server.
getServerSecurityLevel(host) Get server security level.
getServerUsedRam(host) Get the used RAM on a server.
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, cores) 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.
hackAnalyze(host) Get the percent of money stolen with a single thread.
hackAnalyzeChance(host) Get the chance of successfully hacking a server.
hackAnalyzeSecurity(threads) Get the security increase for a number of thread.
hackAnalyzeThreads(host, hackAmount) Predict the effect of hack.
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.
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.
readPort(port) Read data from a port.
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, 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.
tFormat(milliseconds, milliPrecision) Format time to readable string
toast(msg, variant) Queue a toast (bottom-right notification).
tprint(msg) Prints a value or a variable to the Terminal.
tprintf(format, values) Prints a raw value or a variable to the Terminal.
tryWritePort(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.
writePort(port, data) Write data to a port.