The main class used to create & use Prompts.

Example

const prompt: Prompt = new Prompt(PromptType.Choice,"ExamplePrompt","Example message") || new Prompt(PromptType.Compact,"ExamplePrompt","Example message") || new Prompt(PromptType.Custom,"ExamplePrompt","Example message");
prompt.OnFulfill.Connect((accepted: boolean,payload: PromptPayload) => {
if (accepted && payload) {
if (payload.PromptContent.has("SomeInstanceName")) // Do something with data
}
prompt.Destroy();
});

prompt.OnCancel.Connect((reason?: string) => {
warn("Prompt was cancelled for reason: " + reason);
// Other logic upon cancel
prompt.Destroy();
});


// Tips:

// - You don't have to destroy the prompt, after it's first prompt it can be reused.

// - A prompt message that is passed into the contructor is used to display a text label automatically for you with text inside of it
// TODO: It will later be accessible through a function that will allow you to change some properties.

Type Parameters

Constructors

  • Type Parameters

    Parameters

    • promptType: Custom
    • title: string

      The title of this Prompt.

    • message: undefined | string

      The message of this Prompt or undefined for no message.

    • UI: UIResolver

      The UIResolver that is provided to link custom instances to the intended structure.

    Returns Prompt<T>

Properties

Message?: string

The message of the Prompt. This is optional and when toggled a TextLabel will be added to content for you with your specified message.

Options: PromptOptions = ...

The configurable options of this Prompt. See PromptOptions

TimeOut: number = 0

The timeout of this Prompt, when a prompt times out it will fullfill as declined.

Default Value

0 when no timeout will be present, and the prompt will function indefinitely until {@link Prompt.Destroy}.
Title: string

The title of the Prompt.

Validator?: ((payload) => boolean)

A property that is meant to store a validate function that will be fired before Prompt.OnFulfill is called; and will only be called if this function returns true.

Type declaration

    • (payload): boolean
    • A property that is meant to store a validate function that will be fired before Prompt.OnFulfill is called; and will only be called if this function returns true.

      Parameters

      Returns boolean

      boolean - True if the prompt payload is valid, false otherwise.

Param: payload

The PromptPayload data of the Prompt.

Returns

boolean - True if the prompt payload is valid, false otherwise.

This Prompts UIResolver.

_cancelled: boolean = false

Whether the Prompt was cancelled or not.

_destroyed: boolean = false

Whether the Prompt has been destroyed or not.

_timer?: T extends TimerType
    ? Timer<T>
    : undefined

The Timer of this Prompt used for time management.

_triggered: boolean = false

Whether the Prompt is already triggered or not.

_type: PromptType

The type of this Prompt.

Methods

  • Parameters

    • Optional reason: string

      The reason for cancelling the prompt.

    Returns void

  • This method releases used resources and Destroys this Prompt.

    Returns void

  • This method exposes _timer allowing you to set custom timer objects for your custom prompts.

    Parameters

    Returns void

  • Triggers the prompt showing the prompt on top of the players screen. If a time out is specified, a timer will start if no input is given and the prompt will auto-fullfill with a declined status.

    Returns void

  • Private

    Cleans the UI Connections that belong to this Prompt.

    Returns void

  • Private

    This starts and handles the prompts internal timing and functionality when Prompt.TimeOut is assigned.

    Returns void

Events

OnCancel: Signal<[reason?: string]> = ...

This event is fired when a prompt is cancelled for external reasons.

OnFulfill: Signal<[accepted: boolean, payload?: PromptPayload<T>]> = ...

This event is fired when an input or timeout is received.

Generated using TypeDoc