Skip to content
Julian Murgia edited this page Jun 22, 2017 · 3 revisions

TreeNode node

The purpose of the TreeNode custom node is to provide a set of functions allowing the execution of the tree that is defined in the TreeNodeResource attached to it.

Initialization

Simply add the TreeNode as a child of the node you want to define a dialog tree.

A TreeNode alone is useless: it needs a specific Resource to get its data from. You must therefore create a new TreeNodeResource in the inspector for your TreeNode. TreeNodeResource is a custom resource provided by the plugin.

My Unicorn.

Note: as of Godot Engine 2.1, it is not possible to select a custom resource in this combobox, so you have to create a Resource, clic the > button next to it, and attach the res://addons/tree-tools/TreeNode/TreeNodeResource.gd script to it. It is then considered as a TreeNodeResource. You can also link an existing TreeNodeResource *.tres file instead.

When the TreeNode has a TreeNodeResource attached, you can start building your dialog tree by selecting it in the scene tree.

Execution

You can connect your game dialog system to a TreeNode by connecting it to the advance_state*() functions of the TreeNode.

advance_state()

This method advances the current state of execution of the dialog tree by stepping forward to the next(s) step(s). There can be one or more nexts steps, so this method returns a list of next steps.

advance_state_option(option_node_id, option_block_id)

Same as advance_state() but takes in parameter an Option node ID and the block ID within this node chosen to advance to next(s) step(s).

Clone this wiki locally