Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export async function serverAppend(serverList, toAppend) {
- //for each server in toAppend
- ns.tprint("it gets this far at least");
- toAppend.forEach(function(item, index, array) {
- //if serverList does not contain the new server
- if (serverList.includes(item)) {
- ns.tprint("already in there");
- }
- else {
- ns.tprint("oh no");
- }
- });
- //then add the new server to serverList
- }
- export async function main(ns) {
- let serverList = [];
- //test: serverList will have the scan values in it already
- serverList.splice(0, 5, 1, 2, 3, 4, 5);
- ns.write(1, [1, 2, 3, 4, 5]);
- {
- //While true
- while (true) {
- //Check port 1 for more servers
- if (ns.peek(1) == "NULL PORT DATA") {
- ns.tprint(ns.peek(1));
- } else {
- //If there are more servers in port 1
- //call the serverAppend function
- ns.tprint("theres something in there");
- let serversToRead = ns.read(1);
- serverAppend(serverList, serversToRead);
- }
- //wait 30 seconds
- await ns.sleep(2000);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement