UI
The UI namespace provides methods to show notifications, toast messages and input dialogs to the player.
Required permission: ui
Import
typescript
import { UI } from "@hotbunny/hackhub-content-sdk";Methods
UI.notify(message)
Show a notification popup to the player. Appears as a system-style notification.
| Parameter | Type | Description |
|---|---|---|
message | string | Notification text |
typescript
UI.notify("New quest available!");
UI.notify("You received a file from an unknown sender.");UI.toast(message, type?)
Show a brief toast message at the bottom of the screen.
| Parameter | Type | Description |
|---|---|---|
message | string | Toast message text |
type | "success" | "error" | "warning" | "info" | Toast style (optional, defaults to info) |
typescript
UI.toast("File downloaded successfully", "success");
UI.toast("Connection failed", "error");
UI.toast("Low disk space", "warning");
UI.toast("Scanning network...", "info");UI.prompt(options?)
Ask the player for a line of text. Resolves with what they typed, or null when they cancel.
Where it asks depends on the caller. Inside a mod command the player is already typing in a terminal, so the question is asked there. Anywhere else (quest code, a mod app) it opens a dialog.
| Option | Type | Description |
|---|---|---|
title | string | Heading of the dialog (optional) |
label | string | Label shown above the input (optional) |
placeholder | string | Placeholder text (optional) |
password | boolean | Masks the input, for passphrases and keys (optional) |
defaultValue | string | Value the input starts with (optional) |
typescript
const key = await UI.prompt({ label: "WPA passphrase:", password: true });
if (key) await Network.connectWifi("HOME_5Ghz", key);