Dialogs - MarkusBordihn/BOs-Easy-NPC GitHub Wiki
Dive into the world of dialog systems, where creating engaging conversations for NPCs becomes a breeze. Explore various dialog types tailored for complex dialogues and diverse use cases.
Let's kick things off with placeholders available for all dialog types. The dialog text supports additional placeholders, allowing for personalized and dynamic text.
Placeholder | Description |
---|---|
@npc | Name of the NPC |
@initiator | Name of the initiator of the dialog |
This opens the door to text like Hello @initiator, my name is @npc!
🌟
The dialog text supports a variety of formatting options to enhance the conversation. The following formatting placeholders are available.
The following color code placeholders could be used to add color to the dialog text. The the closing tag is only required when the color should be changed back to the default color.
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> |
The following formatting code placeholders could be used to add formatting to the 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> |
The following short code placeholders could be used to add formatting to the dialog text.
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 presents a simple text with a maximum of 255 characters.
The yes/no dialog offers a concise text with a maximum of 255 characters. It includes two buttons for additional actions based on the answer.
In the action screen, define actions for each dialog button.
For the yes
button, grant the player some stone and open the yes_answer
dialog using the
command /give @initiator stone
.
For the no
button, offer the player dirt and open the no_answer
dialog using the
command /give @initiator dirt
.
A preset is available for the above yes/no dialog example.
Spawn a Humanoid (slim)
NPC and import the preset easy_npc:give_dirt_or_stone_to_player
.
The advanced dialog allows for intricate conversations with multiple entries and actions for each entry. While it's the most complex dialog type, modifying a simple or yes/no dialog will automatically convert it to an advanced dialog.
The dialog editor empowers you to create and modify dialog entries.
Options in the dialog editor include:
- The name of the dialog entry
- The label/id of the dialog, used when opening the dialog via a button action.
- The dialog text
- The dialog buttons
The dialog text supports up to 6 text variations, randomly selected for dynamic and engaging conversations.
The button editor allows creation and modification of dialog buttons.
With the Open Dialog
field, define which dialog should open when the button is clicked.
In this case, open the question_on_correct
dialog for the correct answer.
Within the Actions
, summon a firework_rocket
to celebrate the correct answer.
If a button has no Open Dialog
and no Actions
defined, the dialog will close when the button is
clicked.
A preset is available for the above quiz dialog example.
Spawn a Humanoid
NPC and import the preset easy_npc:professor_quiz
.
A default dialog is automatically selected if there is an entry with the label default
, start
,
or main
.
If none of these labels are present, the first dialog entry is automatically selected. For
simplicity, it's recommended to use one of the specified labels for the default dialog.
The dialog system includes a variety of commands to manage and interact with dialogs.
Open a dialog for the player using the command /easy_npc dialog open <NPC-UUID> <Player>
or /easy_npc dialog open <NPC-UUID> <Player> <DialogLabel>
.
The dialog label is optional and will open the default dialog if not specified.
This command could be also triggered by a command block or a function, to allow scripted dialogs.