Bitburner

Bitburner

评价数不足
How to Scan Every Server in Bitburner
由 Bloodly Hell Cat~ 制作
This script will reveal every server in Bitburner, even include those hided ones.
   
奖励
收藏
已收藏
取消收藏
ServersScan
ALERT: Due to Steam's stupid "Formatting help", it will transmit some code to format style. For example: "[" + "i" + "]" will become Italic text . Please take the screenshot as the actual code. Sorry for the inconvenient.
Cut the ♥♥♥♥♥♥♥♥♥, here is the code:



ALERT: Due to Steam's stupid "Formatting help", it will transmit some code to format style. For example: "[" + "i" + "]" will become Italic text . Please take the screenshot as the actual code. Sorry for the inconvenient.

var playerServers = ['home', 'Server1']; var serverChecked = []; var checkList = []; /** @param {NS} ns **/ export async function main(ns) { await ServersScan(ns, 'home'); await printArray(ns, serverChecked); } /** @param {NS} ns **/ async function ServersScan(ns, target) { var servers1 = await ns.scan(target); for (var server in servers1) { if (!checkList.includes(servers1[server])) { checkList.push(servers1[server]); } } serverChecked.push(target); var flag = true; while (flag) { flag = false; for (var i = 0; i < checkList.length; i++) { var servers = await ns.scan(checkList);
if (!serverChecked.includes(checkList)) {
serverChecked.push(checkList);
}
for (var server in servers) {
if (!checkList.includes(servers[server])) {
checkList.push(servers[server]);
}
}
}
}
// remove player servers from serverChecked
for (var server in playerServers) {
for (var i = 0; i < serverChecked.length; i++) {
if (serverChecked == playerServers[server]) {
serverChecked.splice(i, 1);
i--;
}
}
}
}

async function printArray(ns, serverList) {
for (var server in serverList) {
ns.print(serverList[server] + "\n");
ns.tprint(serverList[server] + "\n");
}
}[/code]

User menu:
1. Create a new .js script
nano whateverthenameis.js
2. Copy past the code. I guess everyone knows how to do that!

1) The button on the left button corner of your keyboard which has "ctrl" printed on it, press it down first, hold it, and press "c" meanwhile. Then, release both.
2) Go to the script you just created.
2) Press done "ctrl" again and hold it, and press "v" in the meanwhile.

3. Save it and run it!
run whateverthenameis.js

it should print something like this:

auto.js: n00dles
auto.js: foodnstuff
auto.js: sigma-cosmetics
auto.js: joesguns
auto.js: hong-fang-tea
auto.js: harakiri-sushi
auto.js: iron-gym
auto.js: darkweb
auto.js: max-hardware
auto.js: zer0
auto.js: nectar-net
auto.js: CSEC
auto.js: neo-net
auto.js: phantasy
auto.js: omega-net
auto.js: silver-helix
auto.js: the-hub
auto.js: netlink
auto.js: johnson-ortho
auto.js: avmnite-02h
auto.js: comptek
auto.js: crush-fitness
auto.js: catalyst
auto.js: syscore
auto.js: I.I.I.I
auto.js: rothman-uni
auto.js: summit-uni
auto.js: zb-institute
auto.js: lexo-corp
auto.js: alpha-ent
auto.js: millenium-fitness
auto.js: rho-construction
auto.js: aevum-police
auto.js: galactic-cyber
auto.js: aerocorp
auto.js: global-pharm
auto.js: snap-fitness
auto.js: omnia
auto.js: unitalife
auto.js: deltaone
auto.js: defcomm
auto.js: solaris
auto.js: icarus
auto.js: univ-energy
auto.js: zeus-med
auto.js: infocomm
auto.js: taiyang-digital
auto.js: zb-def
auto.js: nova-med
auto.js: titan-labs
auto.js: applied-energetics
auto.js: microdyne
auto.js: run4theh111z
auto.js: fulcrumtech
auto.js: stormtech
auto.js: helios
auto.js: vitalife
auto.js: kuai-gong
auto.js: .
auto.js: omnitek
auto.js: 4sigma
auto.js: clarkinc
auto.js: powerhouse-fitness
auto.js: b-and-a
auto.js: blade
auto.js: nwo
auto.js: ecorp
auto.js: megacorp
auto.js: fulcrumassets
auto.js: The-Cave


Enjoy!
12 条留言
Softshine798 2023 年 12 月 28 日 下午 12:46 
"ALERT: Due to Steam's stupid "Formatting help", it will transmit some code to format style. For example: "[" + "i" + "]" will become Italic text . Please take the screenshot as the actual code. Sorry for the inconvenient."

I noticed this on the forums whjen I was pasting code. I was able to fix it using [code][noparse] [/code][/noparse]
Dataraven 2022 年 8 月 13 日 上午 11:28 
Here is what I used.

export function allServers(ns) {
var AllServ = ns.scan();
for (var i = 0; i < AllServ.length; ++i) {
var Serv = (AllServ );
var TempServ = [];
var TempServ = ns.scan(Serv.toString());
for (var ii = 0; ii < TempServ.length; ++ii) {
if (AllServ.includes(TempServ[ii])) { }
else { AllServ.push(TempServ[ii]); }
}
}
return AllServ;
}
Budhaman99 2022 年 7 月 29 日 下午 12:06 
If you get Invalid regular expression: missing / make sure you remove [/code] from the end.
ShirtAndTieler 2022 年 1 月 28 日 上午 10:34 
OP just replace your instances of " " with some other variable name...like "idx"...so much easier than needing to have disclaimers everywhere. And as far as I can tell, it's only in three locations. The fixes, as follows:

[code]
for (var idx = 0; idx < checkList.length; idx++) {
var servers = await ns.scan(checkList[idx]);
if (!serverChecked.includes(checkList[idx] )) {
serverChecked.push(checkList[idx] );
[/code]
ArcticZero 2022 年 1 月 3 日 下午 6:32 
maybe upload this to a github gist or something so you can copy and paste the code without going through having to fixing everything
Haghot 2021 年 12 月 31 日 上午 1:09 
good idea - upgrade script for mass root - example

async function printArray(ns, serverList) {
for (var server in serverList) {
//try get root
if (!ns.hasRootAccess(serverList[server])){
await tryhack(ns,serverList[server])
}
//copy worker.js
if (! await ns.fileExists('worker.js',serverList[server])){
await ns.scp("worker.js","home",serverList[server]);
await ns.tprint("copy worker.js to",serverList[server]);
}
//run worker
ns.killall(serverList[server]);
var ram_server = await ns.getServerMaxRam(serverList[server]);
var ram_script = await ns.getScriptRam("worker.js");
var count_treat = await div(ram_server,ram_script);
if(count_treat < 1){ continue;}
await ns.exec("worker.js",serverList[server],count_treat);

}
Rousept 2021 年 12 月 29 日 下午 8:58 
Nice script ! I love how there is so many solutions to the same problem in this game !!

Here is mine, i took advantage of the fact that in JS you can populate an array you are iterating on :)


export function getServersList(ns){
var hosts = ["home"]
for (var i of hosts){
for (let j of ns.scan(i)){
if(!hosts.includes(j) && !ns.getPurchasedServers().includes(j)) {
hosts.push(j)
}
}
}
ns.tprint(hosts)
}
Magic Tiger 2021 年 12 月 29 日 下午 12:51 
OOhh wait didn't see the part about steam formating the code..... time to re-write it.. and see if that is the case
Magic Tiger 2021 年 12 月 29 日 上午 11:27 
@Bloodly Hell Cat~
Seems to still happen, and I've noticed (not sure if related) but the pid continuesly increases with every attempt on running it but it says below the run command:

"[home ~/]> run Find-all-servers.js

Running script with 1 thread(s), pid 834 and args: []."
Bloodly Hell Cat~  [作者] 2021 年 12 月 29 日 上午 10:14 
I believe your problem it's "fixed". @Magic Tiger