Change alert to accept multiple args as other print functions (#2278)

This commit is contained in:
Victor Oliveira
2025-08-04 13:25:06 -03:00
committed by GitHub
parent 89b8497859
commit 2d8401eaae
3 changed files with 13 additions and 8 deletions

View File

@@ -9,14 +9,14 @@ Open up a message box.
**Signature:**
```typescript
alert(msg: string): void;
alert(...args: any[]): void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| msg | string | Message to alert. |
| args | any\[\] | Value(s) to be alerted. |
**Returns:**

View File

@@ -1473,10 +1473,15 @@ export const ns: InternalAPI<NSFull> = {
}
return runningScript.onlineExpGained / runningScript.onlineRunningTime;
},
alert: (ctx) => (_message) => {
const message = helpers.string(ctx, "message", _message);
dialogBoxCreate(message, { html: true, canBeDismissedEasily: true });
},
alert:
(ctx) =>
(...args) => {
if (args.length === 0) {
throw helpers.errorMessage(ctx, "Takes at least 1 argument.");
}
const message = helpers.argsToString(args);
dialogBoxCreate(message, { html: true, canBeDismissedEasily: true });
},
toast:
(ctx) =>
(_message, _variant = ToastVariant.SUCCESS, _duration = 2000) => {

View File

@@ -8109,9 +8109,9 @@ export interface NS {
/**
* Open up a message box.
* @param msg - Message to alert.
* @param args - Value(s) to be alerted.
*/
alert(msg: string): void;
alert(...args: any[]): void;
/**
* Queue a toast (bottom-right notification).