NETSCRIPT: Add undocumented function printRaw() (#277)

This is analagous to tprintRaw (enabled by ns.iKnowWhatImDoing()), but
for logs instead of the terminal. This provides a supported* method of
creating complicated UIs for scripts.

*No actual support, expressed or implied, is provided for use of this
function.
This commit is contained in:
David Walker
2023-01-05 17:30:34 -08:00
committed by GitHub
parent c42fde9379
commit 7b5080a42b
7 changed files with 23 additions and 11 deletions
+6
View File
@@ -1,3 +1,4 @@
import type React from "react";
import { Player } from "../Player";
import { Exploit } from "../Exploits/Exploit";
import * as bcrypt from "bcryptjs";
@@ -16,6 +17,7 @@ export interface INetscriptExtra {
alterReality(): void;
rainbow(guess: string): void;
iKnowWhatImDoing(): void;
printRaw(value: React.ReactNode): void;
}
export function NetscriptExtra(): InternalAPI<INetscriptExtra> {
@@ -82,5 +84,9 @@ export function NetscriptExtra(): InternalAPI<INetscriptExtra> {
// @ts-ignore window has no tprintRaw property defined
window.tprintRaw = Terminal.printRaw.bind(Terminal);
},
printRaw: (ctx) => (value) => {
// Using this voids the warranty on your tail log
ctx.workerScript.print(value as React.ReactNode);
},
};
}