mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 09:42:53 +02:00
rebuild
This commit is contained in:
@@ -683,10 +683,48 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
if (args.length === 0) {
|
||||
throw makeRuntimeErrorMsg("tprint", "Takes at least 1 argument.");
|
||||
}
|
||||
Terminal.print(`${workerScript.scriptRef.filename}: ${argsToString(args)}`);
|
||||
const str = argsToString(args);
|
||||
if (str.startsWith("ERROR") || str.startsWith("FAIL")) {
|
||||
Terminal.error(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
return;
|
||||
}
|
||||
if (str.startsWith("SUCCESS")) {
|
||||
Terminal.success(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
return;
|
||||
}
|
||||
if (str.startsWith("WARN")) {
|
||||
Terminal.warn(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
return;
|
||||
}
|
||||
if (str.startsWith("INFO")) {
|
||||
Terminal.info(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
return;
|
||||
}
|
||||
Terminal.print(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
},
|
||||
tprintf: function (format: any, ...args: any): any {
|
||||
Terminal.print(vsprintf(format, args));
|
||||
if (typeof format !== "string") {
|
||||
throw makeRuntimeErrorMsg("tprintf", "First argument must be string for the format.");
|
||||
}
|
||||
const str = vsprintf(format, args);
|
||||
|
||||
if (str.startsWith("ERROR") || str.startsWith("FAIL")) {
|
||||
Terminal.error(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
return;
|
||||
}
|
||||
if (str.startsWith("SUCCESS")) {
|
||||
Terminal.success(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
return;
|
||||
}
|
||||
if (str.startsWith("WARN")) {
|
||||
Terminal.warn(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
return;
|
||||
}
|
||||
if (str.startsWith("INFO")) {
|
||||
Terminal.info(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
return;
|
||||
}
|
||||
Terminal.print(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
},
|
||||
clearLog: function (): any {
|
||||
workerScript.scriptRef.clearLog();
|
||||
@@ -902,7 +940,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
const server = safeGetServer(hostname, "exec");
|
||||
return runScriptFromScript("exec", server, scriptname, args, workerScript, threads);
|
||||
},
|
||||
spawn: function (scriptname: any, threads: any, ...args: any[]): any {
|
||||
spawn: function (scriptname: any, threads: any = 1, ...args: any[]): any {
|
||||
updateDynamicRam("spawn", getRamCost("spawn"));
|
||||
if (!scriptname || !threads) {
|
||||
throw makeRuntimeErrorMsg("spawn", "Usage: spawn(scriptname, threads)");
|
||||
|
||||
Reference in New Issue
Block a user