Interaction Context
For this tutorial we recommend reading the Interactions guide as we will build upon this.
In this tutorial, you will learn about interaction contexts and how to use them. We will create an interaction where the player needs to specify the amount of flowers given.
What is an interaction context?
Interaction contexts is a powerfull concept that allow you to pass variables to subsequent entries in a sequence. This means you can capture user input, store it, and use it later to drive dynamic interactions
whether it's using the input in future steps or triggering actions (like spawning effects on a clicked block). This flexibility makes your stories more adaptive and engaging.
For this tutorial we will use an integer input dialogue
but there are more types like a string input dialogue
.
Creating an input dialogue
In this tutorial, we will create an interaction where the player needs to specify the amount of flowers given. We will use an integer input dialogue to capture the amount of flowers given by the player.
To add an integer input dialogue, go to the top right corner of the panel and click on the + icon. Search for Add Integer Input Dialogue
and add it to your sequence
(For this guide we linked it to the spoken from Interactions).
Configuring the integer input dialogue
Now inside of the integer input dialogue set the text you want. For this guide we will use: How many flowers would you like?
.
If you want you also can configure the range of an integer input dialogue
Adding the give flowers
Now we need to create an event that gets triggered when the player specifies the amount of flowers. Right-click on the Integer Input Dialogue
entry and click on + link with ...
to open the search menu. Search for Give Item
and add it to the page.
If you don't how the Give Item Entry works than you should first read Giving Items
Configuring the give flowers
Now you can configure the give entry. For this guide we will use a Red Tulip
.
For the item you need to use the custom item. As of right now the amount of a serialized item can't be a variable.
Creating the interaction context variable
Now inside the Give Item Entry at the item field create an extra component and select amount. Now at the amount field click on the and search for Add Interaction Context Variable
.
When you have done that you can than select the Integer Input Dialogue
entry at the entry field.
Video Tutorial
Result
Now when the player specifies the amount of flowers, the player will receive the amount of flowers specified.