-
-
Notifications
You must be signed in to change notification settings - Fork 0
PLUGIN Conversation
This guide explains how to create branching, interactive player conversations using the NPC Plugin. By sending a clickable chat message, the NPC can pause its action chain and resume with different behaviors depending on what option the player selects.
Interactive dialogue relies on the Wait Action set to Command Mode. When a player interacts with an NPC, a message displays clickable options in their chat. The NPC freezes the conversation script for that specific player until a response is received, storing their choice as a temporary variable to evaluate in subsequent Condition Actions.
When the player clicks an option, the data is saved into a variable named after your choice key. How you read this variable depends on how you set up your clickable action:
-
Standard Wait Commands: Data is stored sequentially in a
0-indexed bracket list.-
Syntax:
$wait_name[0](e.g.,$quest_choice[0])
-
Syntax:
-
Custom Packet Actions: Data fields are mapped directly to their specified JSON keys inside the brackets.
-
Syntax:
$wait_name[<key>](e.g.,$path_select[choice_id]or$shop_menu[item_index])
-
Syntax:
Follow these steps to set up a basic binary choice dialogue (e.g., a "Yes/No" quest prompt) using standard vanilla chat commands.
Add a Command Action as the first item in your NPC's interaction chain. This transmits a /tellraw command containing the click actions.
tellraw {player} [{"text":"NPC: Do you want to go on a quest? "},{"text":"[Yes]","color":"green","clickEvent":{"action":"run_command","value":"/npc wait @s quest_choice 1"}},{"text":" "},{"text":"[No]","color":"red","clickEvent":{"action":"run_command","value":"/npc wait @s quest_choice 0"}}]
Toggle edit-mode using /npc edit and right-click your NPC to open the editor GUI. Navigate to Click Actions and configure your pipeline following this exact sequence:
- Command Action
- Paste your
/tellrawcommand from Step 1 here. This prints the interactive question in the player's chat line.
- Wait Action (Set to: Command Mode)
- Add a
Waitaction and change its mode from Time mode to Command mode. - Name the wait key precisely:
quest_choice. The script will now freeze execution here for the clicking player, waiting for an input packet.
- Condition Action (For the "Yes" choice)
- Set the expression evaluation to:
$quest_choice[0] == 1 - Open this condition's inner sub-chain and add a Command Action to award the quest:
msg @s Splendid! Let us begin.
- Condition Action (For the "No" choice)
- Set the expression evaluation to:
$quest_choice[0] == 0 - Open this condition's inner sub-chain and add a Command Action to decline:
msg @s Come back if you change your mind.
In newer Minecraft versions, instead of forcing a player to execute a standard text macro like run_command, you can use the native custom click action. When clicked, this fires a direct packet (minecraft:custom_click_action) to the server. The NPC plugin cleanly intercepts this packet behind the scenes without clogging up chat logs or requiring command permissions.
To use this, you must set the action to "custom", format the ID strictly as "npc:<your_wait_key>", and pass a valid JSON string inside the payload.
Crucial Rule: The values inside the payload's JSON keys must be numeric (integers or decimals) for the plugin to process them into operational variables.
tellraw {player} [{"text":"NPC: Choose your path: "},{"text":"[Warrior]","color":"gold","clickEvent":{"action":"custom","id":"npc:path_select","payload":"{\"choice_id\": 1}"}},{"text":" "},{"text":"[Mage]","color":"aqua","clickEvent":{"action":"custom","id":"npc:path_select","payload":"{\"choice_id\": 2}"}}]
Because the custom action maps your JSON keys directly into the plugin's expression system, you skip the sequential [0] index and read your defined payload keys directly inside the brackets:
-
To check if they picked Warrior:
Set your Condition Action expression to:
$path_select[choice_id] == 1 -
To check if they picked Mage:
Set your Condition Action expression to:
$path_select[choice_id] == 2
This keeps the system entirely invisible to the user, bypassing the chat input field entirely for a smoother gameplay experience.