The Godot Community Forums are back up and running! Please read the the announcement post for important information on what happened. Thanks!

Grab line of singleton

weddi_eddyweddi_eddy Posts: 9Member

Here's what I'm thinking:

I have a ton of dialogue in my game. Would it make sense to:
1. Have a singleton called "dialogue".
2. Each line be a string or something.
3. Have my other scenes reference the "dialogue" singleton and pull in the lines they need.

If so, is there a way to do this?


  • What type of dialogues are we talking about? Do you have multiple npcs that you can talk with in different order? Or it's about queue of messages being shown on screen in story order? Or.. ?

  • weddi_eddyweddi_eddy Posts: 9Member

    Here's what I'm thinking (and this is just theory at this point).

    I want to have dialogue on each line like:

    "I like bananas."
    "I like apples."
    "How can you like fruit?"
    "Only weirdos like fruit..."

    I then want to be able to code a cutscene where I have character 1 says line 1, "I like bananas." This is then followed by NPC who says line 3, "How can you like fruit?"

    I already have a cutscene scene where I can feed instructions for any loaded scene as a node (character or NPC) says whatever dialogue I want. Each node has their own function that displays dialogue.

    I suppose I could do this as an array and just call the parts of the array, but this is going to be a BIG array that contains all the dialogue in the game. If that gets loaded in, I'm not sure if it would be optimal.

    I suppose if I create a singleton, that's going to get loaded anyway, but with lines, I figure it would be manageable.

    It would also allow me to translate easily if this game had a future.

  • Why have you skipped line 2 in your example? Does it mean player may choose an answer?

    In case there are going to be multiple paths in the dialog, you may try some of available tools to create dialogs (like +

    In case dialogs are going to be linear (or almost linear) you may create custom Resources to store text in array. But I would not stick to one big array. You allways may create smaller files divided into chapters / story parts.

  • TwistedTwiglegTwistedTwigleg Posts: 3,141Admin
    edited September 16

    I would highly recommend looking at state machines if you are looking to make, or even use really, a dialog system. All dialog systems are ultimately state machines and having a good grasp of how they work can be really beneficial in structuring how you program your dialog system. It's one of those things that really helped me understand how to implement and work with dialog systems.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file