mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-19 14:13:48 +01:00
fix args not beign passed to scripts
This commit is contained in:
parent
28b9c821d2
commit
e0a24cf381
@ -122,29 +122,24 @@ export function wrapAPI(
|
|||||||
helpers: INetscriptHelper,
|
helpers: INetscriptHelper,
|
||||||
wrappedAPI: ExternalAPI,
|
wrappedAPI: ExternalAPI,
|
||||||
workerScript: WorkerScript,
|
workerScript: WorkerScript,
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
||||||
namespace: object,
|
namespace: object,
|
||||||
...tree: string[]
|
...tree: string[]
|
||||||
): WrappedNetscriptAPI {
|
): WrappedNetscriptAPI {
|
||||||
if (typeof namespace !== "object") throw new Error("Invalid namespace?");
|
|
||||||
for (const [key, value] of Object.entries(namespace)) {
|
for (const [key, value] of Object.entries(namespace)) {
|
||||||
switch (typeof value) {
|
if (typeof value === "function") {
|
||||||
case "function": {
|
|
||||||
wrapFunction(helpers, wrappedAPI, workerScript, value, ...tree, key);
|
wrapFunction(helpers, wrappedAPI, workerScript, value, ...tree, key);
|
||||||
break;
|
} else if (Array.isArray(value)) {
|
||||||
}
|
setNestedProperty(wrappedAPI, value, key);
|
||||||
case "object": {
|
} else if (typeof value === "object") {
|
||||||
wrapAPI(helpers, wrappedAPI, workerScript, value, ...tree, key);
|
wrapAPI(helpers, wrappedAPI, workerScript, value, ...tree, key);
|
||||||
break;
|
} else {
|
||||||
}
|
|
||||||
default: {
|
|
||||||
setNestedProperty(wrappedAPI, value, ...tree, key);
|
setNestedProperty(wrappedAPI, value, ...tree, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return wrappedAPI;
|
return wrappedAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This doesn't even work properly.
|
||||||
function setNestedProperty(root: object, value: unknown, ...tree: string[]): void {
|
function setNestedProperty(root: object, value: unknown, ...tree: string[]): void {
|
||||||
let target = root;
|
let target = root;
|
||||||
const key = tree.pop();
|
const key = tree.pop();
|
||||||
|
@ -2596,5 +2596,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
const possibleLogs = Object.fromEntries([...getFunctionNames(ns, "")].map((a) => [a, true]));
|
const possibleLogs = Object.fromEntries([...getFunctionNames(ns, "")].map((a) => [a, true]));
|
||||||
|
|
||||||
const wrappedNS = wrapAPI(helper, {}, workerScript, ns) as unknown as INS;
|
const wrappedNS = wrapAPI(helper, {}, workerScript, ns) as unknown as INS;
|
||||||
|
(wrappedNS as any).args = ns.args;
|
||||||
|
(wrappedNS as any).enums = ns.enums;
|
||||||
return wrappedNS;
|
return wrappedNS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user