Dialogs - MarkusBordihn/BOs-Easy-NPC GitHub Wiki
Step into the world of dialog systems, where creating engaging conversations for NPCs is easy. Learn about different dialog types designed for complex interactions and various scenarios.
Let's start with placeholders available for all dialog types. These placeholders let you create personalized and dynamic text in your dialogs.
Placeholder | Description |
---|---|
@npc | Name of the NPC |
@initiator | Name of the person starting the dialog |
For example, you can write Hello @initiator, my name is @npc!
๐
You can use various formatting options to make your dialog text stand out. Here are the available placeholders for text formatting:
Use these placeholders to add color to your dialog text. You only need the closing tag if you want to change the color back to the default.
Placeholder | Formatting Code | Color Name | Example |
---|---|---|---|
<black> |
ยง0 |
Black | <black>Text</black> |
<dark_blue> |
ยง1 |
Dark Blue | <dark_blue>Text</dark_blue> |
<dark_green> |
ยง2 |
Dark Green | <dark_green>Text</dark_green> |
<dark_aqua> |
ยง3 |
Dark Aqua | <dark_aqua>Text</dark_aqua> |
<dark_red> |
ยง4 |
Dark Red | <dark_red>Text</dark_red> |
<dark_purple> |
ยง5 |
Dark Purple | <dark_purple>Text</dark_purple> |
<gold> |
ยง6 |
Gold | <gold>Text</gold> |
<gray> |
ยง7 |
Gray | <gray>Text</gray> |
<dark_gray> |
ยง8 |
Dark Gray | <dark_gray>Text/dark_gray> |
<blue> |
ยง9 |
Blue | <blue>Text</blue> |
<green> |
ยงa |
Green | <green>Text</green> |
<aqua> |
ยงb |
Aqua | <aqua>Text</aqua> |
<red> |
ยงc |
Red | <red>Text</red> |
<light_purple> |
ยงd |
Light Purple | <light_purple>Text/light_purple> |
<yellow> |
ยงe |
Yellow | <yellow>Text</yellow> |
<white> |
ยงf |
White | <white>Text</white> |
Use these placeholders to add different styles to your dialog text.
Placeholder | Formatting Code | Example |
---|---|---|
<obfuscated> |
ยงk |
<obfuscated>Text</obfuscated> |
<bold> |
ยงl |
<bold>Text</bold> |
<strikethrough> |
ยงm |
<strikethrough>Text</strikethrough> |
<underline> |
ยงn |
<underline>Text</underline> |
<italic> |
ยงo |
<italic>Text</italic> |
<reset> |
ยงr |
<reset>Text</reset> |
You can also use these short codes for quick formatting.
Short Code | Equivalent Formatting Code | Example |
---|---|---|
<b> |
<bold> |
<b>Text</b> |
<i> |
<obfuscated> |
<i>Text</i> |
<u> |
<underline> |
<u>Text</u> |
<s> |
<strikethrough> |
<s>Text</s> |
The basic dialog displays simple text with a maximum of 255 characters.
The Yes/No dialog provides short text (up to 255 characters) and includes two buttons for actions based on the player's response.
In the action screen, you can define what happens when each button is clicked.
For the Yes
button, you can give the player some stone and open the yes_answer
dialog using the
command /give @initiator stone
.
For the No
button, you can give the player dirt and open the no_answer
dialog using the command
/give @initiator dirt
.
A preset for the Yes/No dialog example is available.
You can spawn a Humanoid (slim)
NPC and import the preset easy_npc:give_dirt_or_stone_to_player
.
The advanced dialog allows for more complex conversations with multiple entries and actions for each one. If you modify a basic or Yes/No dialog, it will automatically become an advanced dialog.
The dialog editor helps you create and modify dialog entries.
Options include:
- The name of the dialog entry
- The label/id of the dialog, used when opening the dialog via a button action
- Whether the dialog entry is the default dialog
- The dialog text
- The dialog buttons
Note: Only one dialog entry can be set as the default dialog.
The dialog text supports up to 6 text variations, which are chosen randomly to make the conversation more dynamic.
The button editor lets you create and modify dialog buttons.
You can define the button text and what actions should happen when the button is clicked.
You can trigger several actions in a specific order.
For example, with the Open Named Dialog
action, you can specify which dialog should open when the
button is clicked.
Here, you could open the question_on_correct
dialog for the right answer.
With the Command
action, you could summon a firework_rocket
to celebrate the correct answer.
If no actions are defined for a button, the dialog will close when the button is clicked.
You can also close the dialog using the Close Dialog
action.
A preset is available for a quiz dialog example. You can spawn a Humanoid
NPC and import the
preset easy_npc:professor_quiz
.
A default dialog is selected automatically if there is an entry with the label default
, start
,
or main
.
If none of these labels exist, the first dialog entry will be selected.
To keep it simple, itโs best to use one of these labels for the default dialog.
You can also use the "Default" button in the dialog editor to mark an entry as the default dialog.
Alternatively, you can use the following command to set the default dialog:
/easy_npc dialog set default <NPC-UUID> <Dialog Label>
The dialog system includes several commands to manage and interact with dialogs.
You can open a dialog for the player using this command:
/easy_npc dialog open <NPC-UUID> <Player>
To open a specific dialog entry, use this command:
/easy_npc dialog open <NPC-UUID> <Player> <DialogLabel>
This command can also
be triggered by a command block, function, or other mods for scripted dialogs.
The dialog system supports translations for dialog texts, making it easy to internationalize your content. For more details on setting up translations, please refer to the Translations page.