Skip to content
Germán edited this page Mar 3, 2024 · 8 revisions

Dialogue Nodes - Documentation

⚠️ Note: Dialogue Nodes for C# is a fork of Nagi's Dialogue Nodes which makes it compatible with C#. You need to be aware that Godot Extensions and C# aren't good friends and you might step into bugs in the plugin. For that reason, it is advised to keep a backup of your game project or use a VCS to revert any damage that the plugin may cause. Currently, on version 4.2.1, there is an ugly Godot-related bug that makes the addon lose any serialized reference exposed with C#. To avoid a headache, use VCS!

Introduction

Dialogue Nodes is a plugin made for the Godot game engine to assist in the creation of branching dialogues and display the dialogues in your games. The plugin adds a new editor tab which you would use for creating, editing, and testing your dialogues. Additionally, the plugin also introduces a new Node: DialogueBox, which you can add to your scene to display dialogues in your game. The focus of this plugin is to keep the process of adding dialogues to your game as intuitive, simple, and straightforward as can be.

Installation And Setup

The installation might be a bit tricky and you need to rely on version control to make this work... after copying and pasting the plugin into your project, Godot might complain about missing classes... that happens because Godot is attempting to load an addon that isn't compiled (we are using C#, and we need to compile the addon!). Make sure you don't open any addon-related scene before compiling, otherwise, scenes that contain serialized exposed fields might lose their references; that is a Godot bug that I hope gets solved, so if you step into some missing classes or signal error or null references when loading the addon.. check that the addon scenes didn't lose their references, try to use version control to recover the addon's original state if that's the case.

To install the addon:

  1. Open https://github.com/germanbv/DialogueNodesForCSharp in your web browser.
  2. Copy the addons/dlaogue_nodes and example folders and paste them into your project.
  3. This is a C# plugin and currently on 4.2.1; C# plugins have a tricky behavior, you must have created a C# solution to make this work as we need the editor to have compiled the plugin before we load it.
  4. In case you don't have a C# solution, go to Project > Tools > C# > Create C# Solution.
  5. Now you should be able to "Build a project" (Alt+B) so that the plugin compiles.
  6. I suggest you restart Godot at this point.
  7. Go to Project > Project Settings > Plugins and Enable Dialogue Nodes for C#.
  8. Done!

image Copy the addons folder from the download to your project's root project. If you want to explore the ready-made examples, copy the examples folder as well.

How to create your dialogues in the editor

  1. Once the plugin has been enabled, open the Dialogue Nodes tab
  2. Now you can either create a new dialogue or open an existing one by clicking on File > New Tree or File > Open...
  3. Try opening one of the Resource files contained in the examples folder to learn how it works.

image

How to use it in your Game

You can explore the Demo scene within the example folder to learn how to use this tool. However, usage is pretty straightforward:

  1. Instantiate a DialogueBox scene to get access to the dialogue manager.
  2. Make sure you call Initialize() from the DialogueManager class while loading your scene.
  3. Now you can run your DialogueData resource generated by the plugin by calling Start().
  4. (Optional) Start() accepts two parameters: a DialogueData file and a DialogueID, leaving these values blank will make the system read the default values defined in the DialogueBox exposed fields in the inspector, but you can always pass your own DialogueData or ID programmatically.

image

Using BBCode and Special FX

This dialogue manager has been made compatible with BBCode... you can add special FX by using tags such as [color=blue][tornado][shake][wave][rainbow] or [fade]. Additionally, I've added new tags for you to experiment with:

  1. colormod: [colormod color=red][/colormod]
  2. cuss: [cuss][/cuss]
  3. ghost: [ghost][/ghost]
  4. heart: [heart scale=1.0 freq=8.0][/heart]
  5. jump: [jump angle=3.141][/jump]
  6. l33t: [l33t][/l33t]
  7. nervous: [nervous scale=1.0 freq=8.0][/nervous]
  8. number: [number][/number]
  9. rain: [rain][/rain]
  10. sparkle: [sparkle c1=red c2=yellow c3=blue][/sparkle]
  11. uWu: [uwu][/uwu]
  12. woo: [woo scale=1.0 freq=8.0][/woo]

*Some of these FXs will need a monospaced font to display correctly.

130072369-90f99c72-358e-41fe-af4d-cfea32665741.mp4

How to use Dialogue Transitions

  • v1.6 supports two kinds of transitions: Wait and Console; you can alternate among them or completely disable them by selecting TransitionType in the DialogueBox instance.
  • You can choose whether you want to make a small pause during punctuation or not by setting the PunctuationPause value (set it to 0 to disable that option).
  • Set the text speed by setting Text Speed

image

How to use Internal Variables

One of the cool features of the original addon was the ability to create variables and get or set their values while the dialogue was running. I've ported that feature to C# with the difference of having to include static types, meaning that you need to declare the variables on the editor before using them:

image

As you can see in the example, under Variables I've declared two variables Coin and Name which I'm able to call by using {{}}, in this case {{Name}} will cast "Germán" while {{Coin}} will cast 50.

image

Similarly, you can use the SetNode to change the value of an internal variable:

image

*Be aware that C# uses static types and you can't assign a value of a different type to a variable, so, if your variable is a string assigning an integer will throw an error.

ConditionalNodes work similarly, you can use internal variables to check for conditions but if the variables are of a different type, the condition will return false.

How to use External Variables

External variables function similarly to internal variables, with the distinction that you must inform the dialogue manager about them before utilizing them. Upon examining the Demo.cs script, you'll notice that immediately after initializing the dialogueBox, I invoke: dialogueBox.AddExternalVariable(externalVariablesDemo). The externalVariablesDemo is merely a random class containing several public fields accessible within my dialogues through {{}} after calling AddExternalVariable:

image

As you can see, I can also use SetNode to set an external variable or ConditionalNodes to check against an external variable.

I've also added the method ClearExternalVariables() as part of DialogueManager.cs to reset the dictionary. Every time the system detects the key {{, it will check for both internal and external variables... is it wise to clear the dictionary if you think you don't need access to external variables anymore.