Dialogue Manager Documentation

repository·main·Indexed 25 days ago

https://github.com/nathanhoad/godot_dialogue_manager

A stateless branching dialogue editor and runtime for Godot. It allows developers to write dialogue in a script-like format with support for branching responses, conditional blocks (if/else, match, while), mutations using the $> operator, and flow control via Cues and Jumps. The tool provides a DialogueManager singleton for displaying dialogue balloons and manually iterating through lines via get_next_dialogue_line. Version 4 is designed for Godot 4.6+, with legacy versions available for Godot 3 and 4.x.

Tokens
9.6K
Snippets
29
Records
67
Agent score
86%

What's inside Dialogue Manager

  1. Use BBCode and special dialogue tags

    main

    Dialogue Manager supports standard Godot BBCode and provides several custom tags for controlling dialogue flow and presentation:

    • [[Option 1|Option 2]]: Picks one option at random from the list (requires double brackets).
    • [wait=N]: Pauses typing for N seconds. Use [wait="ui_accept"] to wait for a specific action, or [wait] to wait for any action. You can also pass an array: [wait=["ui_accept","ui_cancel"]].
    • [speed=N]: Multiplies the default typing speed by N.
    • [next=N]: Waits N seconds before automatically continuing. Use [next=auto] to let the label determine wait time based on text length.
  2. Annotate dialogue with tags

    main

    Use tags to attach metadata to dialogue lines. Tags are wrapped in [# and ].

    • Simple tags: [#tag1, #tag2] adds tags to the tags property of a DialogueLine.
    • Key-value tags: [#key=value] allows you to retrieve specific values using the get_tag_value("key") method on a DialogueLine object.
    Nathan: [#happy, #surprised] Oh, Hello!
    Nathan: [#mood=happy] Oh, Hello!
  3. Upgrade from Dialogue Manager 2 to Dialogue Manager 3

    main

    To upgrade from version 2.x to 3.x:

    1. Remove the addons/dialogue_manager directory.
    2. Download a fresh copy of Dialogue Manager 3 from the Godot Asset Library or GitHub.

    Requirements and Changes:

    • Godot Version: Requires Godot 4.3 or above.
    • Failed Responses: The "include failed responses" setting is removed; failed responses are now included by default. It is the responsibility of the balloon to filter them. The DialogueResponsesMenu node includes an option to hide failed responses.
    • Character Lines: The "create lines for responses with characters" setting has been removed; this must now be handled manually in your game logic.
    • Signal Emitting: The built-in emit mutation is removed. Use standard GDScript signal syntax instead (e.g., some_signal.emit()).
  4. Implement a custom Dialogue Processor

    main

    You can hook into the compilation process to modify dialogue strings either before they are compiled (raw strings) or after they are compiled (compiled lines).

    To implement a processor:

    1. Create a new script that extends DMDialogueProcessor.
    2. Override _preprocess_line(raw_string: String) -> String to modify raw text before compilation.
    3. Override _process_line(line: DMCompiledLine) -> void to modify the compiled line data.
    4. In Godot, go to Project Settings > Dialogue Manager > Editor (ensure Advanced Settings is enabled) and set the dialogue processor path to your script file.
    extends DMDialogueProcessor
    
    func _preprocess_line(raw_string: String) -> String:
      # Modify raw text before compilation
      return raw_string.replace("apples", "oranges")
    
    
    func _process_line(line: DMCompiledLine) -> void:
      # Modify compiled data after compilation
      line.character = "Coco"
  5. Install Dialogue Manager 4

    main

    Dialogue Manager 4 is an addon for Godot 4.6+ that provides a stateless branching dialogue editor and runtime. You can install it using one of the following methods:

    1. Asset Library: Search for and install via the Godot Asset Library.
    2. Manual Download: Download the latest version from GitHub and add it to your project.
    IMPORTANT

    Until Dialogue Manager 4 is officially released, you should probably use version 3.

    https://github.com/nathanhoad/godot_dialogue_manager/archive/refs/heads/main.zip
  6. Use Cues and Jumps to control flow

    main

    Control the flow of dialogue using markers (Cues) and redirection (Jumps):

    • Cues: Define a marker using ~ name. Cues cannot contain spaces.
    • Jump: Redirect flow to a cue using => name.
    • End Flow: Use => END to stop the current dialogue flow, or => END! to force an end regardless of any active 'jump and return' chains.
    • Jump and Return: Use =>< name to jump to a cue and automatically return to the original location once the target cue reaches an END or the end of the file.
    • Inline Jumps: Jumps can be used directly on response lines: - Response => cue_name.
    ~ start
    Nathan: Well?
    - First one
    - Another one => another_cue
    - Start again => start
    => END
    
    ~ another_cue
    Nathan: Another one?
    => END
  7. Customize the example balloon

    main

    To customize the visual appearance of the dialogue balloon without losing changes during updates, use the built-in tool to copy it into your project:

    1. Navigate to the Project > Tools menu in Godot.
    2. Select the option to create a copy of the example balloon into your project.

    Important: Never edit the original example balloon directly, as updates to the addon will overwrite your changes.

    Once copied, you can customize the UI using Godot's UI control nodes. The balloon uses DialogueLabel and DialogueResponsesMenu nodes. The most common way to change the look is by modifying the theme attached to the Balloon panel.