Compare commits

...

2 Commits

Author SHA1 Message Date
677f23ea8d Add script that will contain user created programs 2023-11-03 21:38:19 -03:00
29d88170ab Fix logic bug 2023-11-03 21:38:00 -03:00
2 changed files with 19 additions and 4 deletions

15
servers/home/programs.ts Normal file
View File

@ -0,0 +1,15 @@
import { recursiveScan } from "./utils"
export async function main(ns: NS){
switch (ns.args[0]) {
case "getServers":
getServers(ns);
break;
default:
ns.tprint("Invalid program name");
break;
}
}
function getServers(ns: NS) {
ns.tprint(recursiveScan(ns));
}

View File

@ -97,11 +97,11 @@ export function performFunctionIfCapable(ns: NS, server: string, func: CallableF
} }
if (ns.getServerNumPortsRequired(server) < ns.getServer(server).openPortCount) { if (ns.getServerNumPortsRequired(server) < ns.getServer(server).openPortCount) {
ns.print(`Not enough ports, trying to root ${server}`) ns.print(`Not enough ports, trying to root ${server}`)
}
if (rootServer(ns, server) < ns.getServerNumPortsRequired(server)) { if (rootServer(ns, server) < ns.getServerNumPortsRequired(server)) {
ns.print(`Need more port opening programs to root ${server}`) ns.print(`Need more port opening programs to root ${server}`)
return false return false
} }
}
if (!ns.hasRootAccess(server)) { if (!ns.hasRootAccess(server)) {
ns.print(`Failed to root ${server}`) ns.print(`Failed to root ${server}`)
return false return false