Placeholders
Now that you know conversations, actions, objectives and conditions, it is time to learn about placeholders. Placeholders are small pieces of text that BetonQuest replaces with live values. You can use them to show a player's name, the amount of missing quest items, the result of a condition or a value you defined yourself.
In this tutorial, you will add placeholders to the quest from the previous tutorials.
Related Docs
Download Tutorial Setup
Don't do this if you already have the configs of the previous tutorial step.
Enter this command in the chat to download the pre-made setup for this tutorial:
/bq download BetonQuest/Quest-Tutorials 46e58a65227455571649ab4267bf9cd37a5c0a7c QuestPackages /Basics/Placeholders/1-Setup /tutorialQuest
1. Understanding placeholder syntax🔗
A placeholder starts and ends with a percent sign (%). The text between these signs tells BetonQuest which value
should be inserted.
text: "Hello %player%!"
When the player named Steve sees this text, BetonQuest replaces %player% with Steve.
Most placeholders use this structure:
%placeholder.argument.property%
For example, %item.cod.amount% means:
item- Use the item placeholder.cod- Look at the item namedcodin this QuestPackage.amount- Show how many of this item the player has.
You do not need to remember every placeholder. The placeholders list contains all available placeholders.
2. Using simple placeholders in conversations🔗
You already used %player% in the previous tutorials. Let's add a few more placeholders to the blacksmith conversation.
Open the "blacksmith.yml" file in the "conversations" folder and change the greeting and good luck texts:
| blacksmith.yml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Now also change the lines where the blacksmith talks about the active fishing quest:
| blacksmith.yml | |
|---|---|
1 2 3 4 5 6 7 8 | |
Let's look at the new placeholders:
%player%is replaced with the player's name.%quester%is replaced with the current conversation's quester name. In this example it isBlacksmith.%objective.fishingObj.left%shows how many cod the player still needs for the activefishingObjobjective.%item.cod.amount%shows how manycoditems the player has in their inventory and backpack.
Warning
%objective.fishingObj.left% only works while the player has the fishingObj objective active.
If the player does not have this objective, the placeholder will be empty.
3. Defining reusable text with constants🔗
Sometimes you use the same value in multiple places. For example, the town name or the amount of fish needed for the
quest. You can define these values in the constants section and then use them as placeholders.
Open "package.yml" and add this section:
| package.yml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Now update the blacksmith conversation to use these constants:
| blacksmith.yml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
The constant placeholder is useful when the same text or number appears in multiple places. In this example, the
town name can now be changed in the constants section without editing every conversation line. The fish amount is
also used for the objective, but the item condition and the take action still use cod:3 because those instructions
expect an item amount.
4. Using placeholders in actions and objectives🔗
Placeholders are not limited to conversations. They can also be used in actions or objectives.
Open "objectives.yml" and change the amount of fish to the requiredFish constant:
| objectives.yml | |
|---|---|
1 2 | |
When this objective starts, BetonQuest replaces %constant.requiredFish% with 3. The active objective will keep that
number, even if the constant is changed later.
Now open "actions.yml" and add a notification action:
| actions.yml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
This action sends a chat message with the player's name, the missing cod, the amount of cod already carried and the
result of the hasFishInInv condition. The condition placeholder returns true or false.
Finally, run this action when the player accepts the blacksmith's quest:
| blacksmith.yml | |
|---|---|
1 2 3 4 5 | |
5. Using placeholders in conditions🔗
You can also use placeholders inside conditions. For this example we use the variable condition. It resolves a
placeholder and checks if the result matches a pattern.
Open "conditions.yml" and add this condition:
| conditions.yml | |
|---|---|
1 2 3 4 5 6 7 8 | |
Let's break down the new condition:
variableis the condition type.%player%is resolved before the condition checks the result.A.*is a simple pattern. It matches names that start withA.
Now use this condition in the blacksmith conversation:
| blacksmith.yml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 | |
The conversation checks the options in first from left to right. If the player's name starts with A, the
nameStartsWithA option is used. Otherwise, the normal firstGreeting option is used.
6. Testing placeholders in-game🔗
It is very important to save all files everytime you test something!
Type /bq reload on your server after saving.
Talk to the blacksmith and accept the fishing quest. You should see a message that contains your name and the amount of cod you still need.
You can also run the status action manually after accepting the fishing quest:
/bq action YOUR_NAME tutorialQuest>showQuestStatus
| Command Part | Meaning |
|---|---|
/bq action |
Tells BetonQuest that an action should be executed. |
YOUR_NAME |
Your player name. |
tutorialQuest |
The name of the QuestPackage. |
showQuestStatus |
The name of the action to execute. Don't forget to separate it with the > symbol from the package tutorialQuest>showQuestStatus. |
Testing the cod amount
Use /give YOUR_NAME cod 3 or the creative inventory to give yourself cod.
Then talk to the blacksmith again and check how %item.cod.amount% changes.
Is the example not working?
Get the correct configs by running the following command.
This will overwrite any changes (including NPC ID's and locations) you have made to the example.
Linking NPCs to conversations is explained in the basics tutorial.
/bq download BetonQuest/Quest-Tutorials 46e58a65227455571649ab4267bf9cd37a5c0a7c QuestPackages /Basics/Placeholders/2-FullExample /tutorialQuest overwrite
Summary🔗
You've learned what placeholders are and how to use them in conversations, actions and objective instructions.
You used player, quester, objective, item, condition and constant placeholders. You also used a placeholder inside a
condition with the variable condition type.
More placeholders can be found in the placeholders list.