Skip to content

Commit b161142

Browse files
authored
API: Add ns.renderTail (bitburner-official#1815)
1 parent 97d2484 commit b161142

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed

markdown/bitburner.ns.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export async function main(ns) {
148148
| [readPort(portNumber)](./bitburner.ns.readport.md) | Read data from a port. |
149149
| [relaysmtp(host)](./bitburner.ns.relaysmtp.md) | Runs relaySMTP.exe on a server. |
150150
| [renamePurchasedServer(hostname, newName)](./bitburner.ns.renamepurchasedserver.md) | Rename a purchased server. |
151+
| [renderTail(pid)](./bitburner.ns.rendertail.md) | Render a tail window. |
151152
| [resizeTail(width, height, pid)](./bitburner.ns.resizetail.md) | Resize a tail window. |
152153
| [rm(name, host)](./bitburner.ns.rm.md) | Delete a file. |
153154
| [run(script, threadOrOptions, args)](./bitburner.ns.run.md) | Start another script on the current server. |

markdown/bitburner.ns.rendertail.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [renderTail](./bitburner.ns.rendertail.md)
4+
5+
## NS.renderTail() method
6+
7+
Render a tail window.
8+
9+
**Signature:**
10+
11+
```typescript
12+
renderTail(pid?: number): void;
13+
```
14+
15+
## Parameters
16+
17+
| Parameter | Type | Description |
18+
| --- | --- | --- |
19+
| pid | number | _(Optional)_ Optional. PID of the script having its tail rendered. If omitted, the current script is used. |
20+
21+
**Returns:**
22+
23+
void
24+
25+
## Remarks
26+
27+
RAM cost: 0 GB
28+
29+
Tail windows are rendered at an interval defined in game settings. This function renders the tail window of the specified script immediately.
30+

src/Netscript/RamCostGenerator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ export const RamCosts: RamCostTree<NSFull> = {
599599
tail: 0,
600600
toast: 0,
601601
moveTail: 0,
602+
renderTail: 0,
602603
resizeTail: 0,
603604
closeTail: 0,
604605
setTitle: 0,

src/NetscriptFunctions.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,17 @@ export const ns: InternalAPI<NSFull> = {
566566

567567
LogBoxEvents.emit(runningScriptObj);
568568
},
569+
renderTail:
570+
(ctx) =>
571+
(_pid = ctx.workerScript.scriptRef.pid) => {
572+
const pid = helpers.number(ctx, "pid", _pid);
573+
const runningScriptObj = helpers.getRunningScript(ctx, pid);
574+
if (runningScriptObj == null) {
575+
helpers.log(ctx, () => helpers.getCannotFindRunningScriptErrorMessage(pid));
576+
return;
577+
}
578+
runningScriptObj.tailProps?.rerender();
579+
},
569580
moveTail:
570581
(ctx) =>
571582
(_x, _y, _pid = ctx.workerScript.scriptRef.pid) => {

src/ScriptEditor/NetscriptDefinitions.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6406,6 +6406,19 @@ export interface NS {
64066406
*/
64076407
tail(fn?: FilenameOrPID, host?: string, ...args: ScriptArg[]): void;
64086408

6409+
/**
6410+
* Render a tail window.
6411+
*
6412+
* @remarks
6413+
* RAM cost: 0 GB
6414+
*
6415+
* Tail windows are rendered at an interval defined in game settings. This function renders the tail window of the
6416+
* specified script immediately.
6417+
*
6418+
* @param pid - Optional. PID of the script having its tail rendered. If omitted, the current script is used.
6419+
*/
6420+
renderTail(pid?: number): void;
6421+
64096422
/**
64106423
* Move a tail window.
64116424
* @remarks

0 commit comments

Comments
 (0)