Events
After you learned how to create conversations we will now take a look at events. These allow you to change the game
world. This can be anything from modifying a player's inventory to placing blocks.
In this tutorial, we will give the player items and teleport them to different locations using events.
Requirements
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 refs/tags/v2.1.3 QuestPackages /Basics/Conversations/1-DirectoryStructure /tutorialQuest
1. Creating the folder structure for your first event🔗
Add a new file to your "tutorialQuest" QuestPackage
named "events.yml".
Here is an overview of what your directory structure should look like now:
- tutorialQuest
- package.yml
- events.yml
- conversations
- jack.yml
We now have our file structure ready and can start writing events!
2. Defining your first event🔗
Open the events.yml
now that we have created it and add the following content:
events.yml | |
---|---|
1 2 |
|
- All events must be defined in an
events
section.
So what do we see here?
giveFoodToPlayer
is the name of the event. You are free to choose any name. However, it is recommended to name it after what it does. That just makes it easier to understand your quest.- The Event Instruction.
give
The first value in the instruction is always the event type.steak:16
This is an option of the give event. It defines which item you want to give and which amount seperated by a colon.
Before we can test if the event works ingame we have to create the item steak
because BetonQuest doesn't know what a steak
is.
3. Creating the item in the items section🔗
For some event types like give
you need to specify an item in the items
section.
It holds definitions of all items you want to create/use in your quest.
We will create the item section in the "package.yml" file.
package.yml | |
---|---|
1 2 3 4 5 |
|
- Links the
steak
item name from your BetonQuest configs to the ingameminecraft:COOKED_BEEF
item.
Now steak
is an item name that can be used throughout your quest.
4. Integrating events into conversations🔗
Let's run the event from your conversation.
Tip: Highlighted lines in blue are new compared with the previous example.
jack.yml | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
- The tutorial will only show relevant parts of the examples from now on.
- The event argument must contain one or multiple event names. These events are executed when the corresponding
option is shown to the player.
This argument can be used on both player and npc options.
Make these changes to your conversation, reload and test! The NPC should now give the player food.
5. Testing your first event ingame🔗
You can also run events using commands.
It is very important to save all files everytime you test something!
Type /bq reload
on your server after saving.
The easiest way to do this is by running a command:
Enter /bq event NAME tutorialQuest.giveFoodToPlayer
on the server.
This command will give you the specified amount of steak if you've done everything right!
Command Part | Meaning |
---|---|
/bq event |
Tells BetonQuest that some event should be executed. |
NAME |
A player's name. |
tutorialQuest |
The name of a QuestPackage. This is required because you could have events with the same name in different packages. |
giveFoodToPlayer |
The name of the event to execute. Don't forget to separate it with a dot from the package tutorialQuest.giveFoodToPlayer . |
You can also run this command from the console (without the slash at the start).
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 refs/tags/v2.1.3 QuestPackages /Basics/Events/1-FirstEvent /tutorialQuest overwrite
6. Creating folder events🔗
Now we will create a tour through the mayors city. Meanwhile, we will learn about the teleport and folder events.
Open the "events.yml" file and add these lines:
events.yml | |
---|---|
1 2 3 4 5 6 7 |
|
- Adjust the coordinates and world name to your world. It must be in the unified location format
- Adjust the coordinates and world name to your world. It must be in the unified location format
- Adjust the coordinates and world name to your world. It must be in the unified location format
- Adjust the coordinates and world name to your world. It must be in the unified location format
As you can see, there are a few new events of the types folder
and teleport
.
The folder event wraps multiple events inside itself. Once triggered, it simply executes its events.
Every event type is documented in the events list, read more about the folder
and teleport events there.
Running the townTour
event will teleport you to a new location every five seconds
until we get to our final destination, the blacksmith. The folder event is done after the tpBlacksmith
event was run.
Danger
Make sure you are in creative mode when testing this event. Otherwise, you might die from fall- or suffocation damage.
Running /gamemode creative
will change your game mode to creative.
Now we will add the folder event to Jack's conversation.
jack.yml | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
- The player once again has a choice.
- This is the event name for the new event that we will create. It gets triggered when the
startTheTour
NPC option is shown. - This extends the existing conversation.
These modifications allow the player to choose whether they want to take a town tour or not.
Now speak with the NPC again to take the tour.
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 refs/tags/v2.1.3 QuestPackages /Basics/Events/2-TownTour /tutorialQuest overwrite
Summary🔗
You've learned what events are and how to create them. You can now give a player some food or even teleport him through the whole town! More events can be found in the events list. Next you will learn how to give tasks to the player using objectives.