From b7fdcdf35d7e5a14551f5472b914e3a1d589c114 Mon Sep 17 00:00:00 2001 From: VictorS Date: Wed, 30 Aug 2023 16:36:34 -0400 Subject: [PATCH] DOCS: Improved documentation for functions that take a FilenameOrPID (#759) --- markdown/bitburner.ns.fileexists.md | 2 -- markdown/bitburner.ns.getrunningscript.md | 6 +++--- markdown/bitburner.ns.isrunning.md | 6 +++--- src/ScriptEditor/NetscriptDefinitions.d.ts | 15 ++++++++++----- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/markdown/bitburner.ns.fileexists.md b/markdown/bitburner.ns.fileexists.md index 789f132e4..14b2c6fe4 100644 --- a/markdown/bitburner.ns.fileexists.md +++ b/markdown/bitburner.ns.fileexists.md @@ -31,8 +31,6 @@ RAM cost: 0.1 GB Returns a boolean indicating whether the specified file exists on the target server. The filename for programs is case insensitive, other file types are case sensitive. For example, fileExists(“brutessh.exe”) will work fine, even though the actual program is named 'BruteSSH.exe'. -\* - ## Example diff --git a/markdown/bitburner.ns.getrunningscript.md b/markdown/bitburner.ns.getrunningscript.md index 52d9dcd26..3c0c4bee0 100644 --- a/markdown/bitburner.ns.getrunningscript.md +++ b/markdown/bitburner.ns.getrunningscript.md @@ -21,8 +21,8 @@ getRunningScript( | Parameter | Type | Description | | --- | --- | --- | | filename | [FilenameOrPID](./bitburner.filenameorpid.md) | _(Optional)_ Optional. Filename or PID of the script. | -| hostname | string | _(Optional)_ Optional. Name of host server the script is running on. | -| args | (string \| number \| boolean)\[\] | Arguments to identify the script | +| 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. | **Returns:** @@ -34,5 +34,5 @@ The info about the running script if found, and null otherwise. RAM cost: 0.3 GB -Running with no args returns current script. If you use a PID as the first parameter, the hostname and args parameters are unnecessary. +Running with no args returns current script. If you use a PID as the first parameter, the hostname and args parameters are unnecessary. If hostname is omitted while filename is used as the first parameter, hostname defaults to the server the calling script is running on. Remember that a script is semi-uniquely identified by both its name and its arguments. (You can run multiple copies of scripts with the same arguments, but for the purposes of functions like this that check based on filename, the filename plus arguments forms the key.) diff --git a/markdown/bitburner.ns.isrunning.md b/markdown/bitburner.ns.isrunning.md index 698345bb6..e4da20aa9 100644 --- a/markdown/bitburner.ns.isrunning.md +++ b/markdown/bitburner.ns.isrunning.md @@ -17,8 +17,8 @@ isRunning(script: FilenameOrPID, host?: string, ...args: (string | number | bool | Parameter | Type | Description | | --- | --- | --- | | script | [FilenameOrPID](./bitburner.filenameorpid.md) | Filename or PID of script to check. This is case-sensitive. | -| host | string | _(Optional)_ Hostname of target server. | -| args | (string \| number \| boolean)\[\] | Arguments to specify/identify which scripts to search for. | +| 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. | **Returns:** @@ -30,7 +30,7 @@ True if the specified script is running on the target server, and false otherwis RAM cost: 0.1 GB -Returns a boolean indicating whether the specified script is running on the target server. If you use a PID instead of a filename, the hostname and args parameters are unnecessary. Remember that a script is semi-uniquely identified by both its name and its arguments. (You can run multiple copies of scripts with the same arguments, but for the purposes of functions like this that check based on filename, the filename plus arguments forms the key.) +Returns a boolean indicating whether the specified script is running on the target server. If you use a PID instead of a filename, the hostname and args parameters are unnecessary. If hostname is omitted while filename is used as the first parameter, hostname defaults to the server the calling script is running on. Remember that a script is semi-uniquely identified by both its name and its arguments. (You can run multiple copies of scripts with the same arguments, but for the purposes of functions like this that check based on filename, the filename plus arguments forms the key.) ## Example diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 157e33bff..77ef28a94 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -5830,7 +5830,7 @@ export interface NS { * For example, fileExists(“brutessh.exe”) will work fine, even though the actual program * is named 'BruteSSH.exe'. * - * * @example + * @example * ```js * // The function call will return true if the script named foo.js exists on the foodnstuff server, and false otherwise. * ns.fileExists("foo.js", "foodnstuff"); @@ -5851,6 +5851,7 @@ export interface NS { * * Returns a boolean indicating whether the specified script is running on the target server. * If you use a PID instead of a filename, the hostname and args parameters are unnecessary. + * If hostname is omitted while filename is used as the first parameter, hostname defaults to the server the calling script is running on. * Remember that a script is semi-uniquely identified by both its name and its arguments. * (You can run multiple copies of scripts with the same arguments, but for the purposes of * functions like this that check based on filename, the filename plus arguments forms the key.) @@ -5867,8 +5868,8 @@ export interface NS { * ns.isRunning("foo.js", "joesguns", 1, 5, "test"); * ``` * @param script - Filename or PID of script to check. This is case-sensitive. - * @param host - Hostname of target server. - * @param args - Arguments to specify/identify which scripts to search for. + * @param host - Hostname of target server. Optional, defaults to the server the calling script is running on. + * @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. */ isRunning(script: FilenameOrPID, host?: string, ...args: (string | number | boolean)[]): boolean; @@ -5880,10 +5881,14 @@ export interface NS { * * Running with no args returns current script. * If you use a PID as the first parameter, the hostname and args parameters are unnecessary. + * If hostname is omitted while filename is used as the first parameter, hostname defaults to the server the calling script is running on. + * Remember that a script is semi-uniquely identified by both its name and its arguments. + * (You can run multiple copies of scripts with the same arguments, but for the purposes of + * functions like this that check based on filename, the filename plus arguments forms the key.) * * @param filename - Optional. Filename or PID of the script. - * @param hostname - Optional. Name of host server the script is running on. - * @param args - Arguments to identify the script + * @param hostname - Hostname of target server. Optional, defaults to the server the calling script is running on. + * @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. */ getRunningScript(