ui.open
Creates a distinct view, including repeated opens of the same route. Downloads its resource when needed.
Signature
Section titled “Signature”ui.open<T = UiJson>(player: PlayerTarget, resource: UiResource, options?: UiOpenOptions<T>): UiView<T>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerTarget |
The player. |
resource |
UiResource |
A resource registered by this gamemode. |
options |
UiOpenOptions |
Route, input, failure feedback and optional human interaction. |
Returns
Section titled “Returns”A UiView with separate opened, ready and result promises. Invalid options or a
resource from an earlier gamemode lifetime throw. Operational failures resolve to typed failure outcomes.
Example
Section titled “Example”import { commands, server, ui } from "nativemp";
const menu = await ui.registerResource({ name: "menu", directory: "./menu/dist" });commands.register("menu", async player => { const view = ui.open(player, menu, { interaction: {} }); const result = await view.result; if (result.status === "submit") server.log(`${player.name} submitted ${JSON.stringify(result.value)}`);});Related
Section titled “Related”- HTML UI: page API, input and deadlines
UiInteractionResult