Adding Options to Dialogue
Options are choices presented to the player. When an entry has options, the dialogue pauses until the player chooses one.1
Create an entry with options
Add options to a dialogue entry and specify where each option leads:
2
Display options in your UI
When a dialogue entry has options, create buttons for each one:
3
Handle player choice
When the player clicks an option, tell the DialogueEntry which option was chosen, then advance:
Rejoining Branches
After branching, you often want the dialogue to converge back to a common path:Conditional Branching
Conditional entries let you branch based on game state without showing options to the player:1
Create a condition function
Define a function that returns a boolean:
2
Add a conditional entry
Use
add_conditional_entry() instead of add_text_entry():Conditional entries are evaluated automatically when reached. The player never sees the condition itself - the dialogue just branches silently based on the result.
Complete Example
Entry Methods for Options
Conditional Entry Methods
Best Practices
Always set goto IDs for all options
Always set goto IDs for all options
If you forget to set a goto ID for an option, the dialogue will cancel when that option is chosen.
Use meaningful branch IDs for options
Use meaningful branch IDs for options
Instead of arbitrary numbers, use enums that describe what each branch represents:
Clear options from UI before advancing
Clear options from UI before advancing
Always remove option buttons before calling
advance() to prevent the player from clicking them again.Conditions are evaluated at runtime
Conditions are evaluated at runtime
The condition callable is called when the entry is visited, so you can check any game state (inventory, flags, stats, etc.).
Next Steps
- Use dynamic text to personalize dialogue based on game state
- Learn about save/load to preserve player choices
- Check the debugging guide to visualize your branching dialogue
