Dialog Manager issue

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Kyle J144


I have been following the following tutorial:

[Tutorial I have been following ][1]

But i have ran into a problem as I am receiving an error or line 34 with the DialogManager.gd and this script was already created as it cam with the addon and I am also getting an error on line 34 with the script that is attached to the panel.

The DialogManager.gd script is

extends Node

export (String, FILE, "*.json") var dialog_file = null

var nodes = {}
var conversations = {}
var default_conversation = null
var current

signal new_speech(speech_codes)
signal new_choice(choices)
signal dialog_finished()

func _ready():

func parse_dialog_data():
	if dialog_file:
		var file = File.new()
		file.open(dialog_file, File.READ)
		var data = parse_json(file.get_as_text())
		for graph_node in data["nodes"]:
			#var instance = load("res://addons/dialog_graph/" + data["nodes"][graph_node]["type"]).instance()
			match data["nodes"][graph_node]["type"]:
				"Conversation": create_conversation(data, graph_node)
				"Speech": create_speech(data, graph_node)
				"Choice": create_choice(data, graph_node)
				"Condition": create_condition(data, graph_node)
				"Mux": create_mux(data, graph_node)
				"Jump": create_jump(data, graph_node)

func start_dialog(conversation = default_conversation):
	current = conversations[conversation]

func continue_dialog():

func process():
	if current:
		match nodes[current]["type"]:
				"Conversation": process_conversation()
				"Speech": process_speech()
				"Choice": process_choice()
				"Condition": process_condition()
				"Mux": process_mux()
				"Jump": process_jump()

func create_conversation(data, graph_node):
	var next = null
	if data["sc"].has(graph_node):
		next = data["sc"][graph_node]["0"]["to"]
	nodes[graph_node] = {"type": "Conversation", "next": next}
	conversations[data["nodes"][graph_node]["Line0"]] = graph_node
	if data["default_conversation"] == graph_node:
		default_conversation = data["nodes"][graph_node]["Line0"]

func process_conversation():
	current = nodes[current]["next"]

func create_speech(data, graph_node):
	var next = null
	var size = data["nodes"][graph_node]["Size"]
	if data["sc"].has(graph_node):
		next = data["sc"][graph_node]["0"]["to"]
	nodes[graph_node] = {"type": "Speech", "next": next, "size": size}
	var speech = []
	for i in range(size):
		#nodes[graph_node]["speech" + String(i)] = data["nodes"][graph_node]["Line" + String(i)]
		speech.append(data["nodes"][graph_node]["Line" + String(i)])
	nodes[graph_node]["speech"] = speech

func process_speech():
	emit_signal("new_speech", nodes[current]["speech"])
	current = nodes[current]["next"]

func create_choice(data, graph_node):
	var size = data["nodes"][graph_node]["Size"]
	nodes[graph_node] = {"type": "Choice", "size": size}
	if data["sc"].has(graph_node):
		var next = []
		for i in range(size):
			if data["sc"][graph_node].has(String(i)):
		nodes[graph_node]["next"] = next
	var choice = []
	for i in range(size):
		#nodes[graph_node]["choice" + String(i)] = data["nodes"][graph_node]["Line" + String(i)]
		choice.append(data["nodes"][graph_node]["Line" + String(i)])
	nodes[graph_node]["choice"] = choice

func process_choice():
	emit_signal("new_choice", nodes[current]["choice"])

func choice_picked(choice):
	current = nodes[current]["next"][choice]

func create_condition(data, graph_node):
	var next_true = null
	var next_false = null
	if data["sc"].has(graph_node):
		next_true = data["sc"][graph_node]["0"]["to"]
		next_false = data["sc"][graph_node]["1"]["to"]
	nodes[graph_node] = {"type": "Condition", "next_true": next_true, "next_false": next_false}
	var full_path = data["nodes"][graph_node]["Line0"]
	var split = full_path.find_last("/")
	var path = full_path.substr(0,split)
	var property = full_path.substr(split+1, full_path.length() - 1 - split)
	nodes[graph_node]["path"] = path
	nodes[graph_node]["property"] = property

func process_condition():
	var condition = get_parent().get_node(nodes[current]["path"]).get(nodes[current]["property"])
	if condition:
		current = nodes[current]["next_true"]
		current = nodes[current]["next_false"]

func create_mux(data, graph_node):
	var next = null
	if data["sc"].has(graph_node):
		next = data["sc"][graph_node]["0"]["to"]
	nodes[graph_node] = {"type": "Mux", "next": next}

func process_mux():
	current = nodes[current]["next"]

func create_jump(data, graph_node):
	var next = data["nodes"][graph_node]["Line0"]
	nodes[graph_node] = {"type": "Jump", "to": next}

func process_jump():
	current = conversations[nodes[current]["to"]]

And the panel script is:

extends Panel

onready var dialog_manager = $DialogManager
onready var dialog_text_box : Label = $Label

# Called when the node enters the scene tree for the first time.
func _ready():

func _on_DialogManager_new_speech(speech_codes):
	dialog_text_box.text = speech_codes[0]

Here is a screenshot of the issue:


Any help appreciated and thank you in advance

:bust_in_silhouette: Reply From: Eric Ellingson

The error is telling you exactly what is wrong. You are trying to access conversations[null]. The default value for the parameter conversation is null, so you must be calling start_dialog() without a value somewhere.