Making a simple fetch quest
In this tutorial, we'll create a simple fetch quest where the hero needs to collect 5 flowers and bring them to a granny for a reward.
Playable demo!
You need at least basic skills on working with Whimsy like drawing props and writing scenarios before doing this tutorial. See Writing scenarios to learn how to make them if you need.
Step 1: Draw the actors and props and prepare a stage
The first step will be drawing the needed tiles to make a stage. Here we need to think what needs to be an actor and what can be a prop: actors are interactive and can have scenarios, while props are not interactive and are good for map-making. If you ever get mistaken, remember that you can right-click any prop on the Props tab and turn it into an actor.
Our actors will be:
Granny
;Flower
— we will be able to duplicate them later on a stage, so we need just one actor.
For props, you can draw any number of tiles to make the surroundings: fences, house tiles, maybe trees, shrooms, and grass tufts. I'll also pick the built-in Slimy 05 palette made by green guy on the Lospec site — you can find this palette by pressing the 🎨 button in the bottom part of the palette column.
Step 2: Create the variable to count flowers
First, let's set up a variable to track the number of flowers collected:
- Open the variables manager: go to the Settings tab or press the "Manage variables" button in the Data section of the block library.
- Click "Add variable".
- Name it "flowers".
- Set the type to "Number".
- Make sure the starting value is 0.
Step 2: Write a scenario to pick and count flowers
- Go to the Flower actor
- Open its Scenario tab
- Add these blocks:
- Add a "When touched by a hero" event block
- Connect a "Change a variable" block
- Set its Variable (A) to
flowers
- Set Operation to
A = A + B
- Set Value (B) to 1
- Set its Variable (A) to
- Finally, connect a "Destroy themself" block
The "Change a variable", in our setup, will increase the flowers
variable by 1 every time our hero touches a flower. After that, the flower will remove itself from the stage with the "Destroy themself" block.
Tip: Making it more advanced
The current script works just fine: it counts the flowers and removes them from the field, but we can also add a notification when a player collects the needed amount of flowers. We can change the scenario in this way to check whether we have 5 flowers, and show a message when we collect the 5th:
- Unlink "Destroy themself" and "Change a variable" blocks;
- Add blocks "Branch", "Comparison", and "Read variable". Put the "Branch" between "Change a variable" and "Destroy themself".
- Set up a condition: pick the "flowers" variable in the "Read variable block". Then connect it to the A pin of the Comparison block. In the Comparison block itself, set B to 5. Finally, connect the Result of the Comparison to the Branch.
- Add a new "Say a line" block that will be shown when a hero collects their 5th flower. Connect it to the "Yes" outcome of the Branch block, and also to the block "Destroy themself".
- Connect the "No" outcome of the Branch so the flowers still get destroyed in both cases.
Here I add a Branch block with a connected Comparison to see whether the current number of collected flowers is 5. The comparison tests whether A
equals B
, and we connect the current value of the flowers
variable as that A
. For B
, we simply input the amount of flowers we need with a keyboard. This scenario be run every time a hero touches a flower, so when they touch the 5th, the condition becomes valid and another "Say a line" block will be triggered. In both cases, we need to remember to destroy the flower on a stage.
Step 3: Write a scenario for the Granny
The scenario for the Granny will be similar to the one of the flower's: we need to see whether a hero has collected 5 or more flowers. But, note that compared to the previous flower's scenario, we're using the <
operator instead of =
. This lets a hero collect more than 5 flowers. (You can also switch places of "Say a line" blocks and use the ≥
operator.)
- Add "When touched by a hero" event.
- Add a Branch from the Execution Flow category, and Comparison and Read variable blocks from the Data category.
- In the "Read variable" block, pick the
flowers
variable, and connect this block's output to the Comparison's "A" slot. - In the Comparison, select the
A < B
operation. In the "B" input field, write 5. - Connect the Comparison's Result to the Branch.
- Add two "Say a line" blocks and connect each of them to Branch "Yes" and "No" outcomes. In the "Yes" outcome, write text the Granny will say when you don't have 5 flowers yet. In the "No" outcome, write what Granny says when you bring flowers to her.
Every time a hero interacts with the Granny, she will check whether you have less than 5 flowers. If you don't have enough, she will ask for some. If you have at least 5, she will thank you for your efforts.
Step 4: Track the quest completion
While this scenario can be enough, there are a couple issues with that:
- If we need to check whether we've completed the quest elsewhere, we will need to see whether a hero has at least 5 flowers all the time. This isn't handy. And it doesn't account whether we've even brought them back to the Granny!
- And also, every time we interact with the Granny with 5 or more flowers, she will thank you again and again.
To solve this, we will add another variable that will tell whether we've given the flowers to the Granny. Go to the Settings tab or press the "Manage variables" button in the Data section of the scenario library, and create a new variable "is granny quest complete". Set its type to "Yes/No" and make sure its default state is "No".
With just this single variable, we can make Granny's scenario more logical and believable. And as the "is granny quest complete" variable is already a "Yes/No" value, we can connect it to Branch blocks—and others—directly!
- Add another Branch block and a Read variable block that reads the new variable. Connect them to each other and place the Branch block right after the event. (You will need to unlink the old Branch first.)
- Connect the old Branch to new one's "No" outcome.
- Add a new "Say a line" block and connect it to the empty "Yes" outcome of the first Branch. This will be the text the Granny says when you've already given her the flowers and interact with her again.
- Add a "Write variable" block and connect it right after the "Say a line" block where granny accepts flowers. In the block, pick variable "is granny quest complete" and set its value to "Yes".
(New blocks are highlighted.)
What's important here?
- We add a branch before any previous blocks besides the event to check whether we've already given flowers to the Granny. This prevents the Granny from repeating "Oh, you've collected the flowers" again and again.
- Once we do bring the flowers to her, we change the "is quest complete" variable to "Yes". With the branch mentioned above, this completely blocks off the part of the scenario where granny has not yet received flowers.
You can also add more blocks after the "Write variable" to improve on the scenario and change the game world in some way:
- You can add a block "Show message" with "You gave 5 flowers to the granny".
- If you need to track flowers elsewhere, you probably need to reduce the value of the
flowers
variable by 5 here. (Use the "Change variable" block.) - Though the quest tracking variable allows us to fetch its state later, the Granny can, for example, open a fencegate to some other stage immediately with blocks "Turn all actors" or "Destroy all actors".
That's it!
You now know how to make simple quests in your game where a hero can collect and use items they find on stages. Great job! This is a great way to make your stories more interactive.
Want to try these tasks by yourself to improve your skills?
- Add a sound when a hero picks up a flower, and when the Granny rewards you.
- Make several stages and add exits between them, so the Granny doesn't awkwardly ask to gather flowers that are growing literally directly next to her 🤐
- Add a way to track how many flowers you've already collected. Tip: write
${flowers}
in your dialogues to write the value of a variable onto screen. You can read more about this format in Templating messages.- You can show a message when you collect every flower;
- Or the Granny can tell how many you have when interacted with.