Skip to content

Targets, parameters and inputs

A connection names its target, its input and an optional parameter as plain text. This page shows how that text turns into the nodes, the method and the values used in game.

Targets

The target of a connection, and of keys like call_target, decides which nodes receive the input. Most of the time it is a targetname you gave another entity. The other forms reach groups of things and nodes outside the map.

Target Reaches Use it for
main_door Every entity with that targetname in the same map The normal case, one named entity or several sharing a name
door_* Every targetname starting with door_ Opening a whole set at once. Only a trailing * works
@enemies Every node in the Godot group enemies, anywhere in the tree Things spawned at runtime or placed by game code
!player The first node in the player group Reaching the player when the chain lost the activator
!activator Whoever started the chain, !caller means the same Hurting or teleporting the one who touched a trigger
!self The entity that owns the output An entity acting on itself, like a button that disables itself
/root/Game An absolute node path, it must start with / Autoloads and other game code outside the map

Targetnames are looked up inside the nearest FuncGodotMap, so two maps in one scene cannot reach each other's names. Groups, node paths and !player work across the whole tree, use them when one map has to talk to another.

Note

In Source, !caller is the entity that fired the output. Here it means the same as !activator, use !self for the entity itself.

Runtime changes

Targetname lookups are cached per map for speed. After you spawn or rename named entities at runtime, call TrenchDotIO.invalidate(node) with any node in that map so the next lookup sees them. Renaming means changing the td_targetname meta, the node's name plays no part. Killing an entity needs no call, the cache notices freed nodes.

Nodes made by a spawner have no targetname. Reach them through their group, for example @enemies.

Parameters

The parameter is a value you type into the connection and hand to the input, like 25 for take_damage or a speed for a door. The text becomes the first type it fits:

You type The input receives
25 The integer 25
0.5 The float 0.5
true or false A bool
0 64 0 A Vector3, from three numbers separated by spaces
hello The string "hello", when nothing else fits

A JSON array like [10, "$activator"] spreads into several arguments, for inputs that take more than one. Values are converted to the types the method declares, so 1234 reaches a String argument as text. When the method takes a node before any other argument, text like !player or a targetname is looked up and passed in as that node.

A parameter can also be one of these placeholders, filled in when the input is called:

Placeholder Becomes
$activator The activator, the node that started the chain
$self, $caller The receiving entity itself
$position The receiving entity's global position
$caller_name The receiving entity's targetname, else its node name

Placeholders are filled in on the receiving entity, not the one that fired. They have to be the whole parameter or a whole array element, they are not replaced inside longer text.

No parameter

Leave the parameter empty and the activator goes into the first argument typed as an object, or untyped and named activator, wherever it sits. That is why take_damage(amount, source) gets it in source. Other values the output carried fill the remaining arguments in order, so changed(value) wired to set_value passes the value on.

That forwards false too, so switched(false) wired to a counter's add adds 0. Set a parameter when you want a fixed value.

How an input is found

When a connection fires, the input name is matched against the target in this order:

  1. A method of that name, or its PascalCase or camelCase spelling, so a C# AddScore answers to add_score.
  2. A property of that name, set to the parameter or the value the output carried. The input speed with parameter 4 changes a door's speed, no extra method needed.
  3. One of the built-in inputs below, which every node understands.
Input Effect
kill Frees the node, removing it from the game
show, enable Makes it visible and lets it process again
hide, disable Makes it invisible and pauses its processing
toggle Flips visibility only, processing is left as it is

The entity's own methods win, so disable on a trigger switches the trigger off instead of hiding it. show and hide are the built-in ones unless the entity's script defines its own. Any other input prints [TD I/O] <node> has no input '<name>'.