Build a quest giver#
A quest giver says something different at every stage of a task: an offer, a reminder, a thank-you with a reward, and a friendly word afterward. You'll build the village elder, who asks the player to find her lost ring, with one Script that picks the right conversation from the quest's state.
Before you begin#
Complete Lock dialogue behind a requirement and Run game actions from a conversation. This guide reuses the Progress Global Variable and the give-gold Command.
Set up the elder:
- In the
VillageCompendium, add an Actor with ActorElderand NameMaren. - Create a game object for her with a Dialogue component and a trigger zone, as in Start a conversation near an NPC.
- Create a Script named
Lost Ringand assign it to her Dialogue component.
Track the quest#
A quest moves through stages, so store it as a number rather than a series of switches. Add two entries to Progress:
| Entry | Type | Starts at | Holds |
|---|---|---|---|
ring-quest |
Number | 0 |
0 before the offer, 1 while the player searches, 2 once it's returned. |
has-ring |
Bool | off | Whether the player is carrying the ring. |
Then add the Conditions and Commands that read and write those entries to the Village Compendium:
| Entry | Configuration |
|---|---|
Condition ring-quest-active |
Compare Numbers: ring-quest Equals 1. |
Condition ring-quest-done |
Compare Numbers: ring-quest Equals 2. |
Condition has-ring |
Boolean reading has-ring. |
Command accept-ring-quest |
Set Number: ring-quest to 1. |
Command complete-ring-quest |
Set Number: ring-quest to 2, then Set Bool: has-ring off. |
Naming each stage keeps the Script readable: @if ring-quest-done says what it checks, where a raw number wouldn't.
Place the ring#
Create a small game object named Ring near your well, with a collider set to Is Trigger. Add an Event with an On Trigger Enter 3D Trigger filtered to the Player tag, and two Instructions:
- Set Bool:
has-ringofProgresson. - Set Active: Game Object
Ring, Is Active off.
The ring doesn't depend on the conversation. The player can find it before or after meeting the elder, and you'll handle both cases.
Route the conversation by stage#
The elder's Script is a chain of @if, @or, and @else, and exactly one branch plays. Write Lost Ring:
@if ring-quest-done
Elder: My ring hasn't left my finger since you brought it back. Thank you.
@or ring-quest-active
Elder: Any luck with my ring? I lost it somewhere near the old well.
@else
Elder: Traveler, could you spare an old woman a moment?
Elder: I lost my mother's ring near the old well, and my eyes aren't what they were.
* I'll find it for you.
@run accept-ring-quest
Elder: Bless you. Bring it back, and I'll make it worth your while.
* Sorry, I'm busy.
Elder: Of course. Young people always are.The chain checks the latest stage first. Once the quest is done, ring-quest-done matches, and the earlier stages are never considered. A player who declines the offer stays at 0, so the elder asks again next time.
Turn in the ring#
While the quest is active, the elder needs two replies: a reminder, or a thank-you if the player has the ring. Nest an @if inside the @or branch:
@if ring-quest-done
Elder: My ring hasn't left my finger since you brought it back. Thank you.
@or ring-quest-active
@if has-ring
Elder: Is that... my ring! You found it!
@run await complete-ring-quest
Elder: Please, take this. It's not much, but it's honest coin.
@run await give-gold [amount: 50]
@else
Elder: Any luck with my ring? I lost it somewhere near the old well.
@else
Elder: Traveler, could you spare an old woman a moment?
Elder: I lost my mother's ring near the old well, and my eyes aren't what they were.
* I'll find it for you.
@run accept-ring-quest
Elder: Bless you. Bring it back, and I'll make it worth your while.
* Sorry, I'm busy.
Elder: Of course. Young people always are.The inner @if and @else form their own chain, indented under @or. complete-ring-quest takes the ring and moves the quest to 2, and give-gold pays the 50 from the line's metadata.
Handle a player who's one step ahead#
A player who explores first may find the ring before the elder ever mentions it. The offer branch can check for that too:
@else
Elder: Traveler, could you spare an old woman a moment?
@if has-ring
Elder: Wait. That ring in your hand... It's my mother's!
@run await complete-ring-quest
@run await give-gold [amount: 50]
Elder: I didn't even get the chance to ask. Thank you.
@else
Elder: I lost my mother's ring near the old well, and my eyes aren't what they were.
* I'll find it for you.
@run accept-ring-quest
Elder: Bless you. Bring it back, and I'll make it worth your while.
* Sorry, I'm busy.
Elder: Of course. Young people always are.Replace the outer @else branch with this version. The player who already has the ring skips straight to the reward, and complete-ring-quest still moves the quest to its final stage.
The Script doesn't care where the state lives
The Script only names Conditions and Commands. If you use the Quests module, rebuild them with its nodes, such as Is Quest Active and Is Quest Completed in the Conditions, and Activate Quest in accept-ring-quest. The Script stays exactly as it is.
Verify the result#
Select Progress so you can watch its values, then enter Play mode:
- Talk to the elder and decline. Talk again, and confirm that she repeats the offer.
- Accept. Confirm that
ring-questis1and that she now asks about the ring. - Pick up the ring, talk to her, and confirm that she thanks you,
ring-questis2,has-ringis off, andgoldrose by50. - Talk once more and confirm the final thank-you.
- Restart Play mode, pick up the ring first, and confirm that she rewards you without offering the quest.
Where to go next#
- Split a story across several Scripts — move each stage into its own Script when the conversation grows.
- Greet the player differently on each visit — vary the reminder line so it doesn't repeat word for word.
- Compendiums — how a chain of
@if,@or, and@elseis evaluated.