Dialog Box
The dialog box system in RPG.js allows you to display text messages and choices to players. It provides a built-in GUI component that handles text display, typewriter effects, and choice selection.Basic Usage
Show Text
TheshowText() method displays a simple text message to the player:
Show Choices
TheshowChoices() method displays a dialog with multiple choices for the player to select from:
Dialog Options
BothshowText() and showChoices() accept an options object with the following properties:
Position
Controls where the dialog box appears on screen:Full Width
Determines if the dialog box takes the full width of the screen:Auto Close
If enabled, the dialog automatically closes after a delay:Typewriter Effect
Controls the typewriter animation effect:Talk With
Makes an event or player turn toward the player during the dialog:Speaker Name
Overrides the speaker label shown in the dialog:Face Display
Shows a character face with a specific expression:Faceset Configuration
To use faces in dialogs, you need to configure the faceset spritesheet on the client side. The faceset is a single image containing multiple character expressions arranged in a grid.Client-side Setup
In your client configuration (config.client.ts), add the faceset spritesheet:
Faceset Parameters
id: Unique identifier for the facesetimage: Path to the faceset image filewidth/height: Dimensions of the faceset imageframesWidth/framesHeight: Number of frames horizontally and vertically in the gridexpressions: Object mapping expression names to their grid positions[frameX, frameY]
Using Faces in Dialogs
Once configured, you can use the faceset in dialogs:Faceset Image Layout
Your faceset image should be organized in a grid. For example, withframesWidth: 3 and framesHeight: 4:
[frameX, frameY] corresponds to a specific expression in your faceset.
Dialog Box Customization
You can customize the appearance and sounds of the dialog box usingprovideClientGlobalConfig() in your client configuration.
Styling the Dialog Box
Customizing Sounds
You can customize the sounds used by the dialog box. The sound IDs inprovideClientGlobalConfig() must correspond to the sound IDs defined in provideClientModules().
See also: Sounds Guide for comprehensive information about sound configuration, dynamic sound resolution, and playing sounds from the server.
box.sounds configuration must match the sound IDs defined in your provideClientModules() configuration. The sounds themselves are loaded through the sounds array in provideClientModules().
Complete Configuration Example
See Also
- Sounds Guide - Comprehensive guide on configuring and using sounds, including dynamic sound resolution