Processing hooks

It is possible to hook into the compilation process in order to modify raw line strings before they are compiled and then also modify compiled lines after they are compiled.

To do so, create a script in your project that extends DMDialogueProcessor and then, in Project Settings > Dialogue Manager > Editor, point "dialogue processor path" at your script file (make sure Advanced is enabled in order to see the setting).

extends DMDialogueProcessor

func _preprocess_line(raw_string: String) -> String:
  # Replace all apples with oranges.
  return raw_string.replace("apples", "oranges")


func _process_line(line: DMCompiledLine) -> void:
  # Make all dialogue to be spoken by Coco.
  line.character = "Coco"

_preprocess_line

func _preprocess_line(raw_string: String) -> String:

Given the raw dialogue line (as a String) before any compiliation has happened and expects a valid dialogue line to be returned (which will then be compiled).

_process_line

func _process_line(line: DMCompiledLine) -> void:

Given each compiled line (as a DMCompiledLine) after it has been compiled.

DMCompiledLine properties

  • id: String - The ID of the line
  • static_id: String = "" - The static line ID (or translation key).
  • type: String = "" - The type of line.
  • character: String = "" - The character name.
  • character_replacements: Array[Dictionary] = [] - Any interpolation expressions for the character name.
  • text: String = "" - The text of the line.
  • text_replacements: Array[Dictionary] = [] - Any interpolation expressions for the text.
  • responses: PackedStringArray = [] - Any response siblings associated with this line.
  • siblings: Array[Dictionary] = [] - Any randomise or case siblings for this line.
  • concurrent_lines: PackedStringArray = [] - Any lines said simultaneously.
  • tags: PackedStringArray = [] - Any tags on this line.
  • expression: Dictionary = {} - The condition or mutation expression for this line.
  • expression_text: String = "" - The express as the raw text that was given.
  • next_id: String = "" - The next sequential line to go to after this line.
  • next_id_expression: Array[Dictionary] = [] - The next line to go to after this line if it is unknown and compile time.
  • is_snippet: bool = false - Whether this jump line should return after the jump target sequence has ended.
  • next_sibling_id: String = "" - The ID of the next sibling line.
  • next_id_after: String = "" - The ID after this line if it belongs to a block (eg. conditions).
  • notes: String = "" - Any doc comments attached to this line.