How do I add branches to dictionary dynamically

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

After working on my dialogue system, I wanted to try to make my own dialogue editor (for both learning and practical uses). Yes, I know there are other dialogue editors.

So, I want to create a node (or instance a template.tscn, really), through code, and have that node be able to assign a value to a dictionary item depending on user input.
When I create a new node as a branch of the previous node, I want the new node node to “inherit” dictionary position of the previous node, and add it´s own.
I´m just not sure how to do this dynamically.

This is how it should work:

node1:
dict[“trunk”]

node2:
dict[“trunk”][“branch”]

node2b:
dict[“trunk”][“branch2”]

node3:
dict[“trunk”][“branch”][“leaf”]

say I have a base node, which represents:

node1:
dict[“trunk”]

I then want to add a node, and a branch to the dictionary at the same time. Adding the branch to a dictionary is not the problem

How do I make the newly created node understand which position in the dictionary it represents? So if I´m on node 2b, it should know to add a value to
dict[“trunk”][“branch2”] without having to hardcode it.

I do hope this doesn´t sound too confusing :stuck_out_tongue: