Adding support for text/select options in Prompt command

This commit is contained in:
Phil
2022-01-30 14:06:18 +00:00
parent 9ddb1c4379
commit 08d0b4cbae
3 changed files with 140 additions and 19 deletions
+3 -2
View File
@@ -1654,7 +1654,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
}else{
workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}' must be a positive power of 2`);
}
return "";
}
@@ -2116,7 +2116,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
message = argsToString([message]);
SnackbarEvents.emit(message, variant, duration);
},
prompt: function (txt: any): any {
prompt: function (txt: any, options?: { type?: string; options?: string[] }): any {
if (!isString(txt)) {
txt = JSON.stringify(txt);
}
@@ -2124,6 +2124,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
return new Promise(function (resolve) {
PromptEvent.emit({
txt: txt,
options,
resolve: resolve,
});
});