mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 09:33:49 +01:00
more api break sad
This commit is contained in:
parent
4f86bc644c
commit
94aa547459
@ -1,3 +1,6 @@
|
|||||||
|
- getScriptExp
|
||||||
|
- getScriptIncome
|
||||||
|
- commitCrime
|
||||||
- Change scp to be (files, destination, source)
|
- Change scp to be (files, destination, source)
|
||||||
- Remove top level sing
|
- Remove top level sing
|
||||||
- Rename stock.buy and stock.sell
|
- Rename stock.buy and stock.sell
|
||||||
|
@ -639,8 +639,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
const singularity = NetscriptSingularity(Player, workerScript);
|
const singularity = NetscriptSingularity(Player, workerScript);
|
||||||
|
|
||||||
const base: InternalAPI<INS> = {
|
const base: InternalAPI<INS> = {
|
||||||
...singularity,
|
|
||||||
|
|
||||||
args: workerScript.args as unknown as any,
|
args: workerScript.args as unknown as any,
|
||||||
enums: {
|
enums: {
|
||||||
toast: ToastVariant,
|
toast: ToastVariant,
|
||||||
@ -1366,9 +1364,13 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
},
|
},
|
||||||
scp:
|
scp:
|
||||||
(ctx: NetscriptContext) =>
|
(ctx: NetscriptContext) =>
|
||||||
async (_scriptname: unknown, _hostname1: unknown, _hostname2?: unknown): Promise<boolean> => {
|
async (
|
||||||
const hostname1 = ctx.helper.string("hostname1", _hostname1);
|
_scriptname: unknown,
|
||||||
const hostname2 = ctx.helper.ustring("hostname2", _hostname2);
|
_destination: unknown,
|
||||||
|
_source: unknown = workerScript.hostname,
|
||||||
|
): Promise<boolean> => {
|
||||||
|
const destination = ctx.helper.string("destination", _destination);
|
||||||
|
const source = ctx.helper.string("source", _source);
|
||||||
if (Array.isArray(_scriptname)) {
|
if (Array.isArray(_scriptname)) {
|
||||||
// Recursively call scp on all elements of array
|
// Recursively call scp on all elements of array
|
||||||
const scripts: string[] = _scriptname;
|
const scripts: string[] = _scriptname;
|
||||||
@ -1378,7 +1380,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
let res = true;
|
let res = true;
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
scripts.map(async function (script) {
|
scripts.map(async function (script) {
|
||||||
if (!(await NetscriptFunctions(workerScript).scp(script, hostname1, hostname2 as any))) {
|
if (!(await NetscriptFunctions(workerScript).scp(script, destination, source))) {
|
||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
@ -1398,31 +1400,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
throw ctx.makeRuntimeErrorMsg("Only works for scripts, .lit and .txt files");
|
throw ctx.makeRuntimeErrorMsg("Only works for scripts, .lit and .txt files");
|
||||||
}
|
}
|
||||||
|
|
||||||
let destServer: BaseServer | null;
|
const destServer = safeGetServer(destination, ctx);
|
||||||
let currServ: BaseServer | null;
|
const currServ = safeGetServer(source, ctx);
|
||||||
|
|
||||||
if (hostname2 != null) {
|
|
||||||
// 3 Argument version: scriptname, source, destination
|
|
||||||
if (scriptName === undefined || hostname1 === undefined || hostname2 === undefined) {
|
|
||||||
throw ctx.makeRuntimeErrorMsg("Takes 2 or 3 arguments");
|
|
||||||
}
|
|
||||||
destServer = safeGetServer(hostname2, ctx);
|
|
||||||
currServ = safeGetServer(hostname1, ctx);
|
|
||||||
} else if (hostname1 != null) {
|
|
||||||
// 2 Argument version: scriptname, destination
|
|
||||||
if (scriptName === undefined || hostname1 === undefined) {
|
|
||||||
throw ctx.makeRuntimeErrorMsg("Takes 2 or 3 arguments");
|
|
||||||
}
|
|
||||||
destServer = safeGetServer(hostname1, ctx);
|
|
||||||
currServ = GetServer(workerScript.hostname);
|
|
||||||
if (currServ == null) {
|
|
||||||
throw ctx.makeRuntimeErrorMsg(
|
|
||||||
"Could not find server hostname for this script. This is a bug. Report to dev.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw ctx.makeRuntimeErrorMsg("Takes 2 or 3 arguments");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scp for lit files
|
// Scp for lit files
|
||||||
if (scriptName.endsWith(".lit")) {
|
if (scriptName.endsWith(".lit")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user