From 3374e806075ddd6c9d069529898d3428b1779f48 Mon Sep 17 00:00:00 2001 From: ztimson Date: Tue, 26 Apr 2022 20:46:41 -0400 Subject: [PATCH] Fixed some bugs --- scripts/copy.js | 2 +- scripts/rootkit.js | 8 ++++++-- scripts/server-manager.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/copy.js b/scripts/copy.js index 134d230..1d7de5e 100644 --- a/scripts/copy.js +++ b/scripts/copy.js @@ -81,7 +81,7 @@ export async function main(ns) { await ns.sleep(500); } ns.killall(args['server']); - const pid = ns.exec(args['file'], args['server'], threads, args['args']); + const pid = ns.exec(args['file'], args['server'], threads, ...args['args']); if(!args['quite']) { ns.tprint(!!pid ? 'Done!' : 'Failed to start'); ns.tprint(''); diff --git a/scripts/rootkit.js b/scripts/rootkit.js index eebe6f0..ed4f723 100644 --- a/scripts/rootkit.js +++ b/scripts/rootkit.js @@ -86,6 +86,11 @@ export async function main(ns) { // Start script if required if(args['script']) { + const threads = args['cpu'] || maxThreads(ns, args['script'], args['server']); + if(!threads) { + ns.tprint(`Server does not have enough RAM to start script.`); + ns.exit(); + } // Copy script & it's dependencies const files = await copyWithDependencies(ns, args['script'], args['server']); if(!args['quite']) { @@ -95,14 +100,13 @@ export async function main(ns) { } // Start the script - const threads = args['cpu'] || maxThreads(ns, args['file'], args['server']) || 1; if(!args['quite']) { ns.tprint(''); ns.tprint(`Executing with ${threads} thread${threads > 1 ? 's' : ''}...`); await ns.sleep(500); } ns.killall(args['server']); - const pid = ns.exec(args['file'], args['server'], threads, args['args']); + const pid = ns.exec(args['script'], args['server'], threads, ...args['args']); if(!args['quite']) { ns.tprint(!!pid ? 'Done!' : 'Failed to start'); ns.tprint(''); diff --git a/scripts/server-manager.js b/scripts/server-manager.js index 513cace..e817e52 100644 --- a/scripts/server-manager.js +++ b/scripts/server-manager.js @@ -52,7 +52,7 @@ export async function main(ns) { ns.purchaseServer(`${serverPrefix}${servers.length}`, args['ram']); // Run the script if requested - if(args['script']) await startScript(`${serverPrefix}${servers.length - 1}`); + if(args['script']) await startScript(`${serverPrefix}${servers.length}`); } else { // Check for upgrades let upgrades = servers.map(server => { // Calculate next RAM upgrades (must be a power of two: 2, 4, 8, 16, 32...)