Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Latest commit

 

History

History
51 lines (34 loc) · 1.16 KB

bitburner.ns.scan.md

File metadata and controls

51 lines (34 loc) · 1.16 KB

Home > bitburner > NS > scan

NS.scan() method

Get the list of servers connected to a server.

Signature:

scan(host?: string): string[];

Parameters

Parameter Type Description
host string (Optional) Optional. Hostname of the server to scan, default to current server.

Returns:

string[]

Returns an array of hostnames.

Remarks

RAM cost: 0.2 GB

Returns an array containing the hostnames of all servers that are one node way from the specified target server. The hostnames in the returned array are strings.

Example

// All servers that are one hop from the current server.
ns.tprint("Neighbors of current server.");
let neighbor = ns.scan();
for (let i = 0; i < neighbor.length; i++) {
    ns.tprint(neighbor[i]);
}
// All neighbors of n00dles.
const target = "n00dles";
neighbor = ns.scan(target);
ns.tprintf("Neighbors of %s.", target);
for (let i = 0; i < neighbor.length; i++) {
    ns.tprint(neighbor[i]);
}