Fixed some bugs

This commit is contained in:
Zakary Timson 2022-04-26 20:46:41 -04:00
parent 7e5bd3031a
commit 3374e80607
3 changed files with 8 additions and 4 deletions

View File

@ -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('');

View File

@ -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('');

View File

@ -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...)