Each dialogue entry belongs to a branch ID. By default, all entries use branch ID 0 (the default branch).
enum { DEFAULT_BRANCH = 0, DIFFERENT_BRANCH_ONE, DIFFERENT_BRANCH_TWO }add_text_entry("This is on the default branch") # Branch 0add_text_entry("This is on branch one", DIFFERENT_BRANCH_ONE)add_text_entry("This is on branch two", DIFFERENT_BRANCH_TWO)
The DialogueEngine will only advance through entries in the current branch unless you use gotos to jump between branches.
extends DialogueEnginefunc _setup() -> void: var first_entry: DialogueEntry = add_text_entry("This is an example of...") add_text_entry("This text will be skipped!") var target_entry: DialogueEntry = add_text_entry("a skipped dialogue!") add_text_entry("Press <Enter> or <Space> to exit.")
2
Set the goto
Use set_goto_id() to jump directly to another entry:
first_entry.set_goto_id(target_entry.get_id())
Now the dialogue will jump from “This is an example of…” directly to “a skipped dialogue!”, skipping the middle entry.
You can jump to entries in different branches to organize your dialogue into logical sections:
extends DialogueEngineenum { DEFAULT_BRANCH = 0, BRANCH_ONE, BRANCH_TWO, BRANCH_THREE }func _setup() -> void: # Start on default branch var first_entry: DialogueEntry = add_text_entry("This is an example of...", DEFAULT_BRANCH) # Jump to a different branch var branch_two_start: DialogueEntry = add_text_entry( "how gotos work against different branch IDs", BRANCH_TWO ) first_entry.set_goto_id(branch_two_start.get_id()) # Continue on branch two add_text_entry( "Once you jump to a different branch ID, the DialogueEngine will only consider entries in that branch ID.", BRANCH_TWO ) # This entry won't be reached (no goto points to it) add_text_entry( "This text will be shown in the debugger but not in the dialogue.", BRANCH_ONE ) add_text_entry("Press <Enter> or <Space> to exit.", BRANCH_TWO)
When you jump to a different branch, the DialogueEngine automatically updates its internal branch ID tracker, so subsequent advance() calls will only consider entries in the new branch.
extends DialogueEnginefunc _setup() -> void: var first_entry: DialogueEntry = add_text_entry("This is an example of...") add_text_entry("This text will be shown on the debugger connected to branch ID 0") add_text_entry( "This text will be shown on the debugger as a separate graph node not connected to branch id 0", 1 ) var first_entry_goto: DialogueEntry = add_text_entry( "a skipped dialogue! Check the debugger out!" ) first_entry.set_goto_id(first_entry_goto.get_id()) add_text_entry("Press <Enter> or <Space> to exit.")