mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-09 17:23:53 +01:00
NETSCRIPT: A minorly breaking change around script launch, and refactoring. (#1213)
This commit is contained in:
parent
7a1fce6f64
commit
384d1c1a2b
@ -9,7 +9,7 @@ Arguments passed into the script.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly args: (string | number | boolean)[];
|
readonly args: ScriptArg[];
|
||||||
```
|
```
|
||||||
|
|
||||||
## Remarks
|
## Remarks
|
||||||
|
@ -9,12 +9,7 @@ Start another script on any server.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
exec(
|
exec(script: string, hostname: string, threadOrOptions?: number | RunOptions, ...args: ScriptArg[]): number;
|
||||||
script: string,
|
|
||||||
hostname: string,
|
|
||||||
threadOrOptions?: number | RunOptions,
|
|
||||||
...args: (string | number | boolean)[]
|
|
||||||
): number;
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -24,7 +19,7 @@ exec(
|
|||||||
| script | string | Filename of script to execute. This file must already exist on the target server. |
|
| script | string | Filename of script to execute. This file must already exist on the target server. |
|
||||||
| hostname | string | Hostname of the <code>target server</code> on which to execute the script. |
|
| hostname | string | Hostname of the <code>target server</code> on which to execute the script. |
|
||||||
| threadOrOptions | number \| [RunOptions](./bitburner.runoptions.md) | _(Optional)_ Either an integer number of threads for new script, or a [RunOptions](./bitburner.runoptions.md) object. Threads defaults to 1. |
|
| threadOrOptions | number \| [RunOptions](./bitburner.runoptions.md) | _(Optional)_ Either an integer number of threads for new script, or a [RunOptions](./bitburner.runoptions.md) object. Threads defaults to 1. |
|
||||||
| args | (string \| number \| boolean)\[\] | Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the third argument threadOrOptions must be filled in with a value. |
|
| args | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the third argument threadOrOptions must be filled in with a value. |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -9,11 +9,7 @@ Get general info about a running script.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
getRunningScript(
|
getRunningScript(filename?: FilenameOrPID, hostname?: string, ...args: ScriptArg[]): RunningScript | null;
|
||||||
filename?: FilenameOrPID,
|
|
||||||
hostname?: string,
|
|
||||||
...args: (string | number | boolean)[]
|
|
||||||
): RunningScript | null;
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -22,7 +18,7 @@ getRunningScript(
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| filename | [FilenameOrPID](./bitburner.filenameorpid.md) | _(Optional)_ Optional. Filename or PID of the script. |
|
| filename | [FilenameOrPID](./bitburner.filenameorpid.md) | _(Optional)_ Optional. Filename or PID of the script. |
|
||||||
| hostname | string | _(Optional)_ Hostname of target server. Optional, defaults to the server the calling script is running on. |
|
| hostname | string | _(Optional)_ Hostname of target server. Optional, defaults to the server the calling script is running on. |
|
||||||
| args | (string \| number \| boolean)\[\] | Arguments to specify/identify the script. Optional, when looking for scripts run without arguments. |
|
| args | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Arguments to specify/identify the script. Optional, when looking for scripts run without arguments. |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Get the exp gain of a script.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
getScriptExpGain(script: string, host: string, ...args: (string | number | boolean)[]): number;
|
getScriptExpGain(script: string, host: string, ...args: ScriptArg[]): number;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -18,7 +18,7 @@ getScriptExpGain(script: string, host: string, ...args: (string | number | boole
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| script | string | Filename of script. |
|
| script | string | Filename of script. |
|
||||||
| host | string | Server on which script is running. |
|
| host | string | Server on which script is running. |
|
||||||
| args | (string \| number \| boolean)\[\] | Arguments that the script is running with. |
|
| args | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Arguments that the script is running with. |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Get the income of a script.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
getScriptIncome(script: string, host: string, ...args: (string | number | boolean)[]): number;
|
getScriptIncome(script: string, host: string, ...args: ScriptArg[]): number;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -18,7 +18,7 @@ getScriptIncome(script: string, host: string, ...args: (string | number | boolea
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| script | string | Filename of script. |
|
| script | string | Filename of script. |
|
||||||
| host | string | Server on which script is running. |
|
| host | string | Server on which script is running. |
|
||||||
| args | (string \| number \| boolean)\[\] | Arguments that the script is running with. |
|
| args | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Arguments that the script is running with. |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Get all the logs of a script.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
getScriptLogs(fn?: FilenameOrPID, host?: string, ...args: (string | number | boolean)[]): string[];
|
getScriptLogs(fn?: FilenameOrPID, host?: string, ...args: ScriptArg[]): string[];
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -18,7 +18,7 @@ getScriptLogs(fn?: FilenameOrPID, host?: string, ...args: (string | number | boo
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| fn | [FilenameOrPID](./bitburner.filenameorpid.md) | _(Optional)_ Optional. Filename or PID of script to get logs from. |
|
| fn | [FilenameOrPID](./bitburner.filenameorpid.md) | _(Optional)_ Optional. Filename or PID of script to get logs from. |
|
||||||
| host | string | _(Optional)_ Optional. Hostname of the server that the script is on. |
|
| host | string | _(Optional)_ Optional. Hostname of the server that the script is on. |
|
||||||
| args | (string \| number \| boolean)\[\] | Arguments to identify which scripts to get logs for. |
|
| args | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Arguments to identify which scripts to get logs for. |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Check if a script is running.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
isRunning(script: FilenameOrPID, host?: string, ...args: (string | number | boolean)[]): boolean;
|
isRunning(script: FilenameOrPID, host?: string, ...args: ScriptArg[]): boolean;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -18,7 +18,7 @@ isRunning(script: FilenameOrPID, host?: string, ...args: (string | number | bool
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| script | [FilenameOrPID](./bitburner.filenameorpid.md) | Filename or PID of script to check. This is case-sensitive. |
|
| script | [FilenameOrPID](./bitburner.filenameorpid.md) | Filename or PID of script to check. This is case-sensitive. |
|
||||||
| host | string | _(Optional)_ Hostname of target server. Optional, defaults to the server the calling script is running on. |
|
| host | string | _(Optional)_ Hostname of target server. Optional, defaults to the server the calling script is running on. |
|
||||||
| args | (string \| number \| boolean)\[\] | Arguments to specify/identify the script. Optional, when looking for scripts run without arguments. |
|
| args | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Arguments to specify/identify the script. Optional, when looking for scripts run without arguments. |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ export async function main(ns) {
|
|||||||
|
|
||||||
| Property | Modifiers | Type | Description |
|
| Property | Modifiers | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [args](./bitburner.ns.args.md) | <code>readonly</code> | (string \| number \| boolean)\[\] | Arguments passed into the script. |
|
| [args](./bitburner.ns.args.md) | <code>readonly</code> | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Arguments passed into the script. |
|
||||||
| [bladeburner](./bitburner.ns.bladeburner.md) | <code>readonly</code> | [Bladeburner](./bitburner.bladeburner.md) | Namespace for bladeburner functions. Contains spoilers. |
|
| [bladeburner](./bitburner.ns.bladeburner.md) | <code>readonly</code> | [Bladeburner](./bitburner.bladeburner.md) | Namespace for bladeburner functions. Contains spoilers. |
|
||||||
| [codingcontract](./bitburner.ns.codingcontract.md) | <code>readonly</code> | [CodingContract](./bitburner.codingcontract.md) | Namespace for codingcontract functions. |
|
| [codingcontract](./bitburner.ns.codingcontract.md) | <code>readonly</code> | [CodingContract](./bitburner.codingcontract.md) | Namespace for codingcontract functions. |
|
||||||
| [corporation](./bitburner.ns.corporation.md) | <code>readonly</code> | [Corporation](./bitburner.corporation.md) | Namespace for corporation functions. Contains spoilers. |
|
| [corporation](./bitburner.ns.corporation.md) | <code>readonly</code> | [Corporation](./bitburner.corporation.md) | Namespace for corporation functions. Contains spoilers. |
|
||||||
|
@ -9,7 +9,7 @@ Start another script on the current server.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
run(script: string, threadOrOptions?: number | RunOptions, ...args: (string | number | boolean)[]): number;
|
run(script: string, threadOrOptions?: number | RunOptions, ...args: ScriptArg[]): number;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -18,7 +18,7 @@ run(script: string, threadOrOptions?: number | RunOptions, ...args: (string | nu
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| script | string | Filename of script to run. |
|
| script | string | Filename of script to run. |
|
||||||
| threadOrOptions | number \| [RunOptions](./bitburner.runoptions.md) | _(Optional)_ Either an integer number of threads for new script, or a [RunOptions](./bitburner.runoptions.md) object. Threads defaults to 1. |
|
| threadOrOptions | number \| [RunOptions](./bitburner.runoptions.md) | _(Optional)_ Either an integer number of threads for new script, or a [RunOptions](./bitburner.runoptions.md) object. Threads defaults to 1. |
|
||||||
| args | (string \| number \| boolean)\[\] | Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument threadOrOptions must be filled in with a value. |
|
| args | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument threadOrOptions must be filled in with a value. |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Terminate current script and start another in a defined number of milliseconds.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
spawn(script: string, threadOrOptions?: number | SpawnOptions, ...args: (string | number | boolean)[]): void;
|
spawn(script: string, threadOrOptions?: number | SpawnOptions, ...args: ScriptArg[]): void;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -18,7 +18,7 @@ spawn(script: string, threadOrOptions?: number | SpawnOptions, ...args: (string
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| script | string | Filename of script to execute. |
|
| script | string | Filename of script to execute. |
|
||||||
| threadOrOptions | number \| [SpawnOptions](./bitburner.spawnoptions.md) | _(Optional)_ Either an integer number of threads for new script, or a [SpawnOptions](./bitburner.spawnoptions.md) object. Threads defaults to 1 and spawnDelay defaults to 10,000 ms. |
|
| threadOrOptions | number \| [SpawnOptions](./bitburner.spawnoptions.md) | _(Optional)_ Either an integer number of threads for new script, or a [SpawnOptions](./bitburner.spawnoptions.md) object. Threads defaults to 1 and spawnDelay defaults to 10,000 ms. |
|
||||||
| args | (string \| number \| boolean)\[\] | Additional arguments to pass into the new script that is being run. |
|
| args | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Additional arguments to pass into the new script that is being run. |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Open the tail window of a script.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
tail(fn?: FilenameOrPID, host?: string, ...args: (string | number | boolean)[]): void;
|
tail(fn?: FilenameOrPID, host?: string, ...args: ScriptArg[]): void;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -18,7 +18,7 @@ tail(fn?: FilenameOrPID, host?: string, ...args: (string | number | boolean)[]):
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| fn | [FilenameOrPID](./bitburner.filenameorpid.md) | _(Optional)_ Optional. Filename or PID of the script being tailed. If omitted, the current script is tailed. |
|
| fn | [FilenameOrPID](./bitburner.filenameorpid.md) | _(Optional)_ Optional. Filename or PID of the script being tailed. If omitted, the current script is tailed. |
|
||||||
| host | string | _(Optional)_ Optional. Hostname of the script being tailed. Defaults to the server this script is running on. If args are specified, this is not optional. |
|
| host | string | _(Optional)_ Optional. Hostname of the script being tailed. Defaults to the server this script is running on. If args are specified, this is not optional. |
|
||||||
| args | (string \| number \| boolean)\[\] | Arguments for the script being tailed. |
|
| args | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Arguments for the script being tailed. |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -9,5 +9,5 @@ Script's arguments
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
args: (string | number | boolean)[];
|
args: ScriptArg[];
|
||||||
```
|
```
|
||||||
|
@ -16,7 +16,7 @@ interface ProcessInfo
|
|||||||
|
|
||||||
| Property | Modifiers | Type | Description |
|
| Property | Modifiers | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [args](./bitburner.processinfo.args.md) | | (string \| number \| boolean)\[\] | Script's arguments |
|
| [args](./bitburner.processinfo.args.md) | | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Script's arguments |
|
||||||
| [filename](./bitburner.processinfo.filename.md) | | string | Script name. |
|
| [filename](./bitburner.processinfo.filename.md) | | string | Script name. |
|
||||||
| [pid](./bitburner.processinfo.pid.md) | | number | Process ID |
|
| [pid](./bitburner.processinfo.pid.md) | | number | Process ID |
|
||||||
| [temporary](./bitburner.processinfo.temporary.md) | | boolean | Whether this process is excluded from saves |
|
| [temporary](./bitburner.processinfo.temporary.md) | | boolean | Whether this process is excluded from saves |
|
||||||
|
@ -9,5 +9,5 @@ Arguments the script was called with
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
args: (string | number | boolean)[];
|
args: ScriptArg[];
|
||||||
```
|
```
|
||||||
|
@ -15,7 +15,7 @@ interface RunningScript
|
|||||||
|
|
||||||
| Property | Modifiers | Type | Description |
|
| Property | Modifiers | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [args](./bitburner.runningscript.args.md) | | (string \| number \| boolean)\[\] | Arguments the script was called with |
|
| [args](./bitburner.runningscript.args.md) | | [ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\] | Arguments the script was called with |
|
||||||
| [filename](./bitburner.runningscript.filename.md) | | string | Filename of the script |
|
| [filename](./bitburner.runningscript.filename.md) | | string | Filename of the script |
|
||||||
| [logs](./bitburner.runningscript.logs.md) | | string\[\] | Script logs as an array. The newest log entries are at the bottom. Timestamps, if enabled, are placed inside <code>[brackets]</code> at the start of each line. |
|
| [logs](./bitburner.runningscript.logs.md) | | string\[\] | Script logs as an array. The newest log entries are at the bottom. Timestamps, if enabled, are placed inside <code>[brackets]</code> at the start of each line. |
|
||||||
| [offlineExpGained](./bitburner.runningscript.offlineexpgained.md) | | number | Total amount of hacking experience earned from this script when offline |
|
| [offlineExpGained](./bitburner.runningscript.offlineexpgained.md) | | number | Total amount of hacking experience earned from this script when offline |
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import type { NetscriptContext } from "./APIWrapper";
|
import type { NetscriptContext } from "./APIWrapper";
|
||||||
|
import type { RunningScript as IRunningScript, Person as IPerson, Server as IServer, ScriptArg } from "@nsdefs";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { killWorkerScript } from "./killWorkerScript";
|
import { killWorkerScript } from "./killWorkerScript";
|
||||||
@ -6,8 +7,6 @@ import { GetAllServers, GetServer } from "../Server/AllServers";
|
|||||||
import { Player } from "@player";
|
import { Player } from "@player";
|
||||||
import { ScriptDeath } from "./ScriptDeath";
|
import { ScriptDeath } from "./ScriptDeath";
|
||||||
import { formatExp, formatMoney, formatRam, formatThreads } from "../ui/formatNumber";
|
import { formatExp, formatMoney, formatRam, formatThreads } from "../ui/formatNumber";
|
||||||
import { ScriptArg } from "./ScriptArg";
|
|
||||||
import { RunningScript as IRunningScript, Person as IPerson, Server as IServer } from "@nsdefs";
|
|
||||||
import { Server } from "../Server/Server";
|
import { Server } from "../Server/Server";
|
||||||
import {
|
import {
|
||||||
calculateHackingChance,
|
calculateHackingChance,
|
||||||
|
@ -1 +0,0 @@
|
|||||||
export type ScriptArg = string | number | boolean;
|
|
@ -1,4 +1,4 @@
|
|||||||
import { ScriptArg } from "./ScriptArg";
|
import type { ScriptArg } from "@nsdefs";
|
||||||
|
|
||||||
//This was previously in INetscriptHelper.ts, may move to its own file or a generic types file.
|
//This was previously in INetscriptHelper.ts, may move to its own file or a generic types file.
|
||||||
export type ScriptIdentifier =
|
export type ScriptIdentifier =
|
||||||
|
@ -12,7 +12,7 @@ import type { NSFull } from "../NetscriptFunctions";
|
|||||||
import type { ScriptFilePath } from "../Paths/ScriptFilePath";
|
import type { ScriptFilePath } from "../Paths/ScriptFilePath";
|
||||||
import type { RunningScript } from "../Script/RunningScript";
|
import type { RunningScript } from "../Script/RunningScript";
|
||||||
import type { Script } from "../Script/Script";
|
import type { Script } from "../Script/Script";
|
||||||
import type { ScriptArg } from "./ScriptArg";
|
import type { ScriptArg } from "@nsdefs";
|
||||||
import type { ScriptDeath } from "./ScriptDeath";
|
import type { ScriptDeath } from "./ScriptDeath";
|
||||||
|
|
||||||
import { Environment } from "./Environment";
|
import { Environment } from "./Environment";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
import type { ScriptArg } from "@nsdefs";
|
||||||
import { toNative } from "./toNative";
|
import { toNative } from "./toNative";
|
||||||
import libarg from "arg";
|
import libarg from "arg";
|
||||||
import { ScriptArg } from "../Netscript/ScriptArg";
|
|
||||||
import { NetscriptContext } from "../Netscript/APIWrapper";
|
import { NetscriptContext } from "../Netscript/APIWrapper";
|
||||||
|
|
||||||
type FlagType = StringConstructor | NumberConstructor | BooleanConstructor | StringConstructor[];
|
type FlagType = StringConstructor | NumberConstructor | BooleanConstructor | StringConstructor[];
|
||||||
|
@ -57,10 +57,12 @@ async function startNetscript2Script(workerScript: WorkerScript): Promise<void>
|
|||||||
const loadedModule = await compile(script, scripts);
|
const loadedModule = await compile(script, scripts);
|
||||||
|
|
||||||
if (!loadedModule) throw `${script.filename} cannot be run because the script module won't load`;
|
if (!loadedModule) throw `${script.filename} cannot be run because the script module won't load`;
|
||||||
|
const mainFunc = loadedModule.main;
|
||||||
// TODO unplanned: Better error for "unexpected reserved word" when using await in non-async function?
|
// TODO unplanned: Better error for "unexpected reserved word" when using await in non-async function?
|
||||||
if (typeof loadedModule.main !== "function")
|
if (typeof mainFunc !== "function")
|
||||||
throw `${script.filename} cannot be run because it does not have a main function.`;
|
throw `${script.filename} cannot be run because it does not have a main function.`;
|
||||||
await loadedModule.main(ns);
|
// Explicitly called from a variable so that we don't bind "this".
|
||||||
|
await mainFunc(ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startNetscript1Script(workerScript: WorkerScript): Promise<void> {
|
async function startNetscript1Script(workerScript: WorkerScript): Promise<void> {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { NSFull } from "../NetscriptFunctions";
|
import type { NSFull } from "../NetscriptFunctions";
|
||||||
import { AutocompleteData } from "@nsdefs";
|
import type { AutocompleteData, ScriptArg } from "@nsdefs";
|
||||||
|
|
||||||
// The object portion of this type is not runtime information, it's only to ensure type validation
|
// The object portion of this type is not runtime information, it's only to ensure type validation
|
||||||
// And make it harder to overwrite a url with a random non-url string.
|
// And make it harder to overwrite a url with a random non-url string.
|
||||||
export type ScriptURL = string & { __type: "ScriptURL" };
|
export type ScriptURL = string & { __type: "ScriptURL" };
|
||||||
|
|
||||||
export interface ScriptModule {
|
export interface ScriptModule {
|
||||||
main?: (ns: NSFull) => unknown;
|
main?: (ns: NSFull, ...args: ScriptArg[]) => unknown;
|
||||||
autocomplete?: (data: AutocompleteData, flags: string[]) => unknown;
|
autocomplete?: (data: AutocompleteData, flags: string[]) => unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
33
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -211,7 +211,7 @@ interface ReactElement {
|
|||||||
/** @public */
|
/** @public */
|
||||||
interface RunningScript {
|
interface RunningScript {
|
||||||
/** Arguments the script was called with */
|
/** Arguments the script was called with */
|
||||||
args: (string | number | boolean)[];
|
args: ScriptArg[];
|
||||||
/** Filename of the script */
|
/** Filename of the script */
|
||||||
filename: string;
|
filename: string;
|
||||||
/**
|
/**
|
||||||
@ -435,7 +435,7 @@ interface ProcessInfo {
|
|||||||
/** Number of threads script is running with */
|
/** Number of threads script is running with */
|
||||||
threads: number;
|
threads: number;
|
||||||
/** Script's arguments */
|
/** Script's arguments */
|
||||||
args: (string | number | boolean)[];
|
args: ScriptArg[];
|
||||||
/** Process ID */
|
/** Process ID */
|
||||||
pid: number;
|
pid: number;
|
||||||
/** Whether this process is excluded from saves */
|
/** Whether this process is excluded from saves */
|
||||||
@ -5365,7 +5365,7 @@ export interface NS {
|
|||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
readonly args: (string | number | boolean)[];
|
readonly args: ScriptArg[];
|
||||||
|
|
||||||
/** The current script's PID */
|
/** The current script's PID */
|
||||||
readonly pid: number;
|
readonly pid: number;
|
||||||
@ -5834,7 +5834,7 @@ export interface NS {
|
|||||||
* @param args - Arguments to identify which scripts to get logs for.
|
* @param args - Arguments to identify which scripts to get logs for.
|
||||||
* @returns Returns a string array, where each line is an element in the array. The most recently logged line is at the end of the array.
|
* @returns Returns a string array, where each line is an element in the array. The most recently logged line is at the end of the array.
|
||||||
*/
|
*/
|
||||||
getScriptLogs(fn?: FilenameOrPID, host?: string, ...args: (string | number | boolean)[]): string[];
|
getScriptLogs(fn?: FilenameOrPID, host?: string, ...args: ScriptArg[]): string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an array of recently killed scripts across all servers.
|
* Get an array of recently killed scripts across all servers.
|
||||||
@ -5884,7 +5884,7 @@ export interface NS {
|
|||||||
* @param host - Optional. Hostname of the script being tailed. Defaults to the server this script is running on. If args are specified, this is not optional.
|
* @param host - Optional. Hostname of the script being tailed. Defaults to the server this script is running on. If args are specified, this is not optional.
|
||||||
* @param args - Arguments for the script being tailed.
|
* @param args - Arguments for the script being tailed.
|
||||||
*/
|
*/
|
||||||
tail(fn?: FilenameOrPID, host?: string, ...args: (string | number | boolean)[]): void;
|
tail(fn?: FilenameOrPID, host?: string, ...args: ScriptArg[]): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move a tail window.
|
* Move a tail window.
|
||||||
@ -6119,7 +6119,7 @@ export interface NS {
|
|||||||
* @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument threadOrOptions must be filled in with a value.
|
* @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument threadOrOptions must be filled in with a value.
|
||||||
* @returns Returns the PID of a successfully started script, and 0 otherwise.
|
* @returns Returns the PID of a successfully started script, and 0 otherwise.
|
||||||
*/
|
*/
|
||||||
run(script: string, threadOrOptions?: number | RunOptions, ...args: (string | number | boolean)[]): number;
|
run(script: string, threadOrOptions?: number | RunOptions, ...args: ScriptArg[]): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start another script on any server.
|
* Start another script on any server.
|
||||||
@ -6159,12 +6159,7 @@ export interface NS {
|
|||||||
* @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the third argument threadOrOptions must be filled in with a value.
|
* @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the third argument threadOrOptions must be filled in with a value.
|
||||||
* @returns Returns the PID of a successfully started script, and 0 otherwise.
|
* @returns Returns the PID of a successfully started script, and 0 otherwise.
|
||||||
*/
|
*/
|
||||||
exec(
|
exec(script: string, hostname: string, threadOrOptions?: number | RunOptions, ...args: ScriptArg[]): number;
|
||||||
script: string,
|
|
||||||
hostname: string,
|
|
||||||
threadOrOptions?: number | RunOptions,
|
|
||||||
...args: (string | number | boolean)[]
|
|
||||||
): number;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminate current script and start another in a defined number of milliseconds.
|
* Terminate current script and start another in a defined number of milliseconds.
|
||||||
@ -6189,7 +6184,7 @@ export interface NS {
|
|||||||
* @param threadOrOptions - Either an integer number of threads for new script, or a {@link SpawnOptions} object. Threads defaults to 1 and spawnDelay defaults to 10,000 ms.
|
* @param threadOrOptions - Either an integer number of threads for new script, or a {@link SpawnOptions} object. Threads defaults to 1 and spawnDelay defaults to 10,000 ms.
|
||||||
* @param args - Additional arguments to pass into the new script that is being run.
|
* @param args - Additional arguments to pass into the new script that is being run.
|
||||||
*/
|
*/
|
||||||
spawn(script: string, threadOrOptions?: number | SpawnOptions, ...args: (string | number | boolean)[]): void;
|
spawn(script: string, threadOrOptions?: number | SpawnOptions, ...args: ScriptArg[]): void;
|
||||||
/**
|
/**
|
||||||
* Terminate the script with the provided PID.
|
* Terminate the script with the provided PID.
|
||||||
* @remarks
|
* @remarks
|
||||||
@ -6586,7 +6581,7 @@ export interface NS {
|
|||||||
* @param args - Arguments to specify/identify the script. Optional, when looking for scripts run without arguments.
|
* @param args - Arguments to specify/identify the script. Optional, when looking for scripts run without arguments.
|
||||||
* @returns True if the specified script is running on the target server, and false otherwise.
|
* @returns True if the specified script is running on the target server, and false otherwise.
|
||||||
*/
|
*/
|
||||||
isRunning(script: FilenameOrPID, host?: string, ...args: (string | number | boolean)[]): boolean;
|
isRunning(script: FilenameOrPID, host?: string, ...args: ScriptArg[]): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get general info about a running script.
|
* Get general info about a running script.
|
||||||
@ -6605,11 +6600,7 @@ export interface NS {
|
|||||||
* @param args - Arguments to specify/identify the script. Optional, when looking for scripts run without arguments.
|
* @param args - Arguments to specify/identify the script. Optional, when looking for scripts run without arguments.
|
||||||
* @returns The info about the running script if found, and null otherwise.
|
* @returns The info about the running script if found, and null otherwise.
|
||||||
*/
|
*/
|
||||||
getRunningScript(
|
getRunningScript(filename?: FilenameOrPID, hostname?: string, ...args: ScriptArg[]): RunningScript | null;
|
||||||
filename?: FilenameOrPID,
|
|
||||||
hostname?: string,
|
|
||||||
...args: (string | number | boolean)[]
|
|
||||||
): RunningScript | null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cost of purchasing a server.
|
* Get cost of purchasing a server.
|
||||||
@ -7020,7 +7011,7 @@ export interface NS {
|
|||||||
* @param args - Arguments that the script is running with.
|
* @param args - Arguments that the script is running with.
|
||||||
* @returns Amount of income the specified script generates while online.
|
* @returns Amount of income the specified script generates while online.
|
||||||
*/
|
*/
|
||||||
getScriptIncome(script: string, host: string, ...args: (string | number | boolean)[]): number;
|
getScriptIncome(script: string, host: string, ...args: ScriptArg[]): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the exp gain of all scripts.
|
* Get the exp gain of all scripts.
|
||||||
@ -7048,7 +7039,7 @@ export interface NS {
|
|||||||
* @param args - Arguments that the script is running with.
|
* @param args - Arguments that the script is running with.
|
||||||
* @returns Amount of hacking experience the specified script generates while online.
|
* @returns Amount of hacking experience the specified script generates while online.
|
||||||
*/
|
*/
|
||||||
getScriptExpGain(script: string, host: string, ...args: (string | number | boolean)[]): number;
|
getScriptExpGain(script: string, host: string, ...args: ScriptArg[]): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount of time in milliseconds that have passed since you last installed Augmentations.
|
* Returns the amount of time in milliseconds that have passed since you last installed Augmentations.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { ScriptArg } from "../../Netscript/ScriptArg";
|
import type { ScriptArg } from "@nsdefs";
|
||||||
import type { ScriptFilePath } from "../../Paths/ScriptFilePath";
|
import type { ScriptFilePath } from "../../Paths/ScriptFilePath";
|
||||||
|
|
||||||
// This needs to be high in the dependency graph, with few/no dependencies of
|
// This needs to be high in the dependency graph, with few/no dependencies of
|
||||||
|
Loading…
Reference in New Issue
Block a user