Update NetscriptFunctions.ts

Just a simple change to make `alert` and `toast` reuse `argsToString` instead of `toNative` and `JSON.stringify` directly.

Fixes #2015.
This commit is contained in:
MageKing17 2021-12-19 16:58:49 -08:00 committed by GitHub
parent 890b1df593
commit e521415273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2131,15 +2131,15 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
return Player.playtimeSinceLastAug;
},
alert: function (message: any): void {
message = toNative(message);
dialogBoxCreate(JSON.stringify(message));
message = argsToString([message]);
dialogBoxCreate(message);
},
toast: function (message: any, variant: any = "success"): void {
if (!["success", "info", "warning", "error"].includes(variant))
throw new Error(`variant must be one of "success", "info", "warning", or "error"`);
message = toNative(message);
SnackbarEvents.emit(JSON.stringify(message), variant);
message = argsToString([message]);
SnackbarEvents.emit(message, variant);
},
prompt: function (txt: any): any {
if (!isString(txt)) {