From 5526355a4374ebd8ef7c76e967571058bd962379 Mon Sep 17 00:00:00 2001 From: Undeemiss Date: Mon, 16 May 2022 19:15:38 -0500 Subject: [PATCH] Set up the skeleton of an ns.closeTail function --- src/NetscriptFunctions.ts | 4 ++++ src/ScriptEditor/NetscriptDefinitions.d.ts | 18 ++++++++++++++++++ src/ui/React/LogBoxManager.tsx | 2 ++ 3 files changed, 24 insertions(+) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 14d953f1f..ed7e2cb8e 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -988,6 +988,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { LogBoxEvents.emit(runningScriptObj); }, + closeTail: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any[]): void { + updateDynamicRam("closeTail", getRamCost(Player, "closeTail")); + // TODO + }, nuke: function (_hostname: unknown): boolean { updateDynamicRam("nuke", getRamCost(Player, "nuke")); const hostname = helper.string("tail", "hostname", _hostname); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 63f6d2250..bdc1a34a8 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -4981,6 +4981,24 @@ export interface NS { */ tail(fn?: FilenameOrPID, host?: string, ...args: any[]): void; + /** + * Close the tail window of a script. + * @remarks + * RAM cost: 0 GB + * + * Closes a script’s logs. This is functionally the same pressing the "Close" button on the tail window. + * + * If the function is called with no arguments, it will close the current script’s logs. + * + * Otherwise, the fn, hostname/ip, and args… arguments can be used to close the logs from another script. + * Remember that scripts are uniquely identified by both their names and arguments. + * + * @param fn - Optional. Filename or PID of the script having its tail closed. If omitted, the current script is used. + * @param host - Optional. Hostname of the script having its tail closed. Defaults to the server this script is running on. If args are specified, this is not optional. + * @param args - Arguments for the script having its tail closed. + */ + closeTail(fn?: FilenameOrPID, host?: string, ...args: any[]): void; + /** * Get the list of servers connected to a server. * @remarks diff --git a/src/ui/React/LogBoxManager.tsx b/src/ui/React/LogBoxManager.tsx index 21839a23b..023f38a19 100644 --- a/src/ui/React/LogBoxManager.tsx +++ b/src/ui/React/LogBoxManager.tsx @@ -131,6 +131,8 @@ function LogWindow(props: IProps): React.ReactElement { return () => clearInterval(id); }, []); + //TODO Not actually a todo I just want this file to show up as changed + //so I can find it easier later function kill(): void { killWorkerScript(script, script.server, true); }