The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I have tried numerous times to make a dialog system. I have tried using Escoria, but I didn't like the bloat that came with it. I tried looking into json, but could not figure out how to get it to work. I have use arrays in Gdscript with some success, but I'm stuck at the moment. It brings up multiple options, but it doesn't load the text after or before.

Current gdscripts
My control.gd

extends Control
var dialogpath = "intro"
onready var container = get_node("scroll/choicecontainer")

var continued #A continued part of the dialog tree
var charname
var page = 0
onready var richtextbox = get_node("RichTextLabel")

func say(confab):
    continued = confab#Stores the data path for later use
    var dialog = load(confab).new()
    charname = name
    var charconfab = dialog.confab[dialogpath]
    if page < charconfab.size():
        richtextbox.set_bbcode(charconfab[page])
        page+=1
        print(page)
    elif page >= charconfab.size():
        page=0
        richtextbox.set_bbcode(charname+": "+charconfab[page])
        page+=1

func choice(dialogoption):
    if dialogoption == null:#WIP
        print("Error dialog returned null")
        return
    var newoption = load(dialogoption).new()
    var option = newoption.dialogchoices
    var i = 0
    while i < option.size():
        #Get a duplicate of the nodes
        var dupchoice = get_node("dupchoice").duplicate()
        var dupbutton = dupchoice.get_node("button")
        var duplabel = dupbutton.get_node("label")
        #Set Properties of the nodes
        duplabel.set_text(option[i])

        dupbutton.connect("pressed",self,"_on_pressed", [i])

        var size = dupchoice.get_custom_minimum_size()
        size.y = size.y + 15
        dupchoice.set_custom_minimum_size(size)

        dupchoice.set_hidden(false)#No longer hidden
        #Adds the Choice duplicates to the Choice container
        container.add_child(dupchoice)
        i+=1

func _on_pressed(integer):
    #Get the Integer for the option of the dialog tree.
    dialogpath = "option"+str(integer)
    print(dialogpath)
    #Remove all the dialog options in the container.
    var dupchoices = container.get_children()
    for delchoices in dupchoices:
        delchoices.queue_free()
    #Continue the dialog
    say(continued, charname)

In dialog.gd, this is reference by a character, by a export(String, FILE)var. If you use Escoria you should know what I mean.

var dialogchoices = ["Oh Yes Option 1 Is good","Option 2 might be better","Over here pick me!"]
var dialoger = {
    intro = ["Hello can you pick an option?","You choose option one?"],
    option0 = ["You choose option 0","NOT 1, Haha."],
    option1 = ["You have option 2/1"],
    option2 = ["YOU PICKED ME!","YAYAYAYAYYAYAYAYYAYAYAYYAYAYAYAYAYYAYAYAYAYAY!"]
}
in Engine by (272 points)

3 Answers

0 votes

I haven't tested Escoria, nor this, but eventually try https://github.com/lemilonkh/twinestory Godot Engine module to import dialogues made with http://twinery.org/

by (340 points)

I'll look into it, thank you.

0 votes

This is not an answer just an idea I haven't tried yet. Would it be possible to create a dialogue node and then create the conversation structure using Godot's visual scripting?

by (251 points)
0 votes

Check this tutorial from TheHappieCat, it uses a free tool (inklewriter) for the dialog system and a simple parser you can look at to start building yours.

https://www.youtube.com/watch?v=aVutIoCGAfE

by (7,890 points)

Not to sound mean, but that was the worst tutorial I had ever watched.
No highlighting important code,
more ums than a buddist monk, people really need to start using a script when they make video tutorials. SO they can have a focused train of thought.
and she didn't form the code while she did the tutorial. Leading to, "If i were to do this correctly" statements.

At least she linked her source code. So thanks happiecat for that.

I don't like video tutorials for coding at all, I go always straight to the source when no text is provided xD

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.