~ startset npc_name = "Bob"if player_level < 5 set npc_name = "Mysterious Stranger"{{npc_name}}: Hello there!{{player_name}}: Who are you?{{npc_name}}: I'm {{npc_name}}, nice to meet you.=> END
Local variables are temporary and only exist during the current conversation:
~ startset locals.counter = 0set locals.player_choice = "none"Nathan: What would you like to know?- Tell me about yourself [if not locals.asked_about_nathan] set locals.asked_about_nathan = true set locals.counter += 1 Nathan: Well, I'm a game developer who loves making dialogue systems. => start- What's your favorite color? [if not locals.asked_favorite_color] set locals.asked_favorite_color = true set locals.counter += 1 Nathan: I'd say blue. It's calming. => start- That's all for now Nathan: You asked me {{locals.counter}} questions! => END
locals is a feature provided by the example balloon for temporary conversation state, not a built-in feature of Dialogue Manager itself. When the conversation ends or changes dialogue files, local variables are deleted.
func _on_dialogue_line(line: DialogueLine) -> void: if "happy" in line.tags: character_sprite.play("happy_animation") if "surprised" in line.tags: play_sound("gasp")
Nathan: [#happy] I'm so glad you're here!Nathan: [#sad] I have some bad news...Nathan: [#angry] How dare you!Nathan: [#neutral] That's interesting.
Use these to trigger facial expressions or animations.
Camera directions
Nathan: [#camera=closeup] This is important.Nathan: [#camera=wide, #focus=background] Look at that view!Coco: [#camera=over_shoulder] Let me show you something.
Use these to control camera movements during dialogue.
Use these to trigger sound effects synchronized with dialogue.
Character animations
Nathan: [#anim=wave] Hello there!Nathan: [#anim=point, #target=door] Through that door.Coco: [#anim=think] Let me consider...
Use these to trigger character animations.
Quest markers
Nathan: [#quest=main_quest_1] Find the ancient artifact.Nathan: [#quest=side_quest_3, #reward=100] Collect 10 herbs.
Use these to associate dialogue with quests.
UI hints
Nathan: [#ui=show_map] Look at your map.Nathan: [#ui=highlight_inventory] Check your inventory.Nathan: [#ui=tutorial_prompt] Press Q to use your ability.
Here’s a complete example using variables and tags:
~ startset locals.conversation_mood = "neutral"Nathan: [#anim=wave, #emotion=happy] Hello, {{player_name}}!Nathan: [#camera=closeup] I see you're level {{player_level}}.if player_level >= 10 set locals.conversation_mood = "impressed" Nathan: [#emotion=impressed] That's quite impressive!elif player_level >= 5 set locals.conversation_mood = "encouraging" Nathan: [#emotion=encouraging] You're making good progress!else set locals.conversation_mood = "supportive" Nathan: [#emotion=supportive] Everyone starts somewhere!Nathan: You have {{gold}} gold and {{inventory_count}} items.if gold < 10 Nathan: [#emotion=concerned] You're running low on gold. Nathan: [#ui=highlight_gold] You should do some quests.Nathan: What would you like to do?- Buy item [if gold >= 50] set gold -= 50 set inventory_count += 1 Nathan: [#anim=give, #sfx=purchase] Here you go! Nathan: You now have {{inventory_count}} items. => start- Sell item [if inventory_count > 0] set gold += 30 set inventory_count -= 1 Nathan: [#anim=take, #sfx=coins] Thanks! Nathan: You now have {{gold}} gold. => start- Check stats Nathan: [#ui=show_stats] Here are your stats: Nathan: Level: {{player_level}} Nathan: Gold: {{gold}} Nathan: Items: {{inventory_count}} Nathan: Mood: {{locals.conversation_mood}} => start- Goodbye Nathan: [#anim=wave, #emotion=friendly] Safe travels, {{player_name}}! => END
Variables in dialogue are evaluated when the line is processed:
# In your game codevar GameState = { "player_name": "Hero", "gold": 150, "level": 5}# Variables are automatically resolved when dialogue runs# "You have {{gold}} gold" becomes "You have 150 gold"
func _on_dialogue_line(line: DialogueLine) -> void: # Check if a tag exists if "happy" in line.tags: print("Character is happy!") # Get all tags print("All tags: ", line.tags) # ["emotion=happy", "anim=wave"] # Get specific tag value var emotion = line.get_tag_value("emotion") if emotion: character.play_emotion(emotion) # Get tag value with default var anim = line.get_tag_value("anim", "idle") character.play_animation(anim) # Handle multiple tags for tag in line.tags: if tag.begins_with("sfx="): var sfx_name = tag.split("=")[1] audio_player.play(sfx_name)
# GoodNathan: You have {{player_health}} health.Nathan: Your sword deals {{weapon_damage}} damage.# UnclearNathan: You have {{h}} health.Nathan: Your sword deals {{d}} damage.