How do you make a none linear dialog system?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lavaduder
:warning: Old Version Published before Godot 3 was released.

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!"]
}
:bust_in_silhouette: Reply From: Omicron

I haven’t tested Escoria, nor this, but eventually try GitHub - lemilonkh/twinestory: A module for the Godot Engine for parsing Twine stories in JSON format Godot Engine module to import dialogues made with http://twinery.org/

I’ll look into it, thank you.

lavaduder | 2017-06-20 18:39

:bust_in_silhouette: Reply From: whooshfrosted

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?

:bust_in_silhouette: Reply From: eons

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.

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.

lavaduder | 2017-06-20 18:35

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

eons | 2017-06-20 19:40